I am having the error:
attempt to index nil with 'Connect' - Client - LocalScript:3
I am trying to make it so that when a string value gets updated, it will update the GUI text with it
local status = game.Workspace.Status.Value
status.Changed:Connect(function()
script.Parent = status
end)
The tutorial that I'm following: Youtube tutorial
It is a local script.
game.Workspace.Status is the StringValue. When you save the .Value into a variable, you aren't holding onto a reference to the StringValue itself, you are copying its value into the variable.
So you fix your problem, you just need your variable to point at the StringValue, not the string stored inside it.
local status = game.Workspace.Status
status.Changed:Connect(function()
script.Parent.Text = status.Value
end)
Related
I am trying to insert an animation into my code for the first time. Here is my code:
1 local player = game.Players.LocalPlayer
2 local char = player.Character or player.CharacterAdded:Wait()
3 local hum = char:WaitForChild("Humanoid")
4
5 local animaInstance = Instance.new("Animation")
6 animaInstance.AnimationId = "rbxassetid://4641537766"
7
8 local fireBallAnim = hum.LoadAnimation(animaInstance)
9 fireBallAnim:Play()
I am getting the error
The function LoadAnimation is not a member of Animation
I know the character has fully loaded, so I don't understand. Could I be getting this error if there is something wrong with the animation itself? What else am I missing out?
Thanks
local fireBallAnim = hum:LoadAnimation(animaInstance)
This is a very confusing message for the error. The only problem is that you've called a member function with a . as opposed to a :. Switching it to a colon will fix your error.
When you call a function on an object with a colon, it is automatically inserting the object as the first argument. A fun example of this can be seen with tables :
-- insert an object into the table 't'
local t = {}
table.insert(t, 1)
-- can also be written as...
t.insert(t, 1)
-- which is the same as...
t:insert(1)
All of these calls do the same thing. Calling the function with : is syntactic sugar for putting the t object as the first argument. So in your code, what's happening is you are calling LoadAnimation like this :
local fireBallAnim = hum.LoadAnimation(<a humanoid object needs to go here>, <animation>)
But since you are passing in the animation where the Humanoid is supposed to go, it is trying to find the LoadAnimation function on the animation object and failing.
I am using this code to connect to server.
'Client-Side Connect Code
sockMain.RemoteHost = 192.168.1.125
sockMain.RemotePort = 12345
sockMain.Connect
'Server Side code to send message to client
sockMain.SendData txtSend.text
Now, if i write :: a="127" , and send it to client from server, then this message will be displayed in textbox on client side , now how can i use this message , a="127" to store variable value ?
You cannot literally create a new named variable within a compiled VB6 application at runtime in the manner described. You can, however, certainly extract the numeric portion of the value in the textbox and assign that value to a local variable in the application.
If you want to capture the numeric portion of the value in the textbox, and you know the text format will always be of the form "a=somenumber," you can strip off the first two characters to eliminate the "a=" portion, and then use the VB `Val' function on the remaining string to capture the numeric value:
' Generalized example for pulling integer portion from
' a textbox of the form 'a=12345'; amend as appropriate. Untested.
Dim a as integer
Dim receivedData as String
' Assuming txtBox1 as the name of the textbox in the client
receivedData = txtBox1.Text
receievedData = mid$(value,3)
a = Val(receivedData)
`
I'm using a script exactly like the one on the tutorial here, https://developers.google.com/apps-script/reference/ui/file-upload
However, despite using the syntax I keep getting e is undefined in the statement:
var fileBlob = e.parameter.dsrFile;
I think that means my function doPost(e) is probably wrong somehow. Here is my entire script below.
// Create Menu to Locate .CSV
function doGet(e) {
var app = UiApp.createApplication().setTitle("Upload CSV");
var formContent = app.createVerticalPanel();
formContent.add(app.createFileUpload().setName("dsrFile"));
formContent.add(app.createSubmitButton("Start Upload"));
var form = app.createFormPanel();
form.add(formContent);
app.add(form);
return app;
}
// Upload .CSV file
function doPost(e)
{
// data returned is a blob for FileUpload widget
var fileBlob = e.parameter.dsrFile;
var doc = DocsList.createFile(fileBlob);
}
e is undefined because you are not passing anything to doPost. You have to pass the needed object to doPost. Check where you call the function and what parameters do you pass to it if any. Even if you pass a parameter to that function, it holds undefined value. Make sure that you are passing the correct objects to your functions.
Your script should work perfectly. e is defined by Google Apps Script, not need to pass anything in particular is contains the fields of your form, in particular in this case the file you uploaded.
I would suspect you may be falling foul to the dev url vs publish url syndrome, where you are executing an old scrip rather that the code you are currently working on.
Be sure you script end with 'dev' and not 'exec'
https://script.google.com/a/macros/appsscripttesting.com/s/AKfyck...EY7qzA7m6hFCnyKqg/dev
Let me know if you are still getting the error after running it from the /dev url
I'm retrieving the files that match a given query in my drive account using a wrapper that I created
files = get_files_by_query session, "title = 'Competitors' and trashed = false"
This returns an Array of Google::APIClient::Schema::Drive::V2::File objects
From the rails console I'm able to retrieve the parents of the first file in the array.
files.first.parents.first.id
However, when I attempt to retrieve the isRoot
files.first.parents.first.isRoot
I get the following error
TypeError: Expected boolean, got NilClass.
Which is very strange because when I inspect the contents of the parent, the hash is displayed and isRoot is clearly false or true, but never nil.
Not sure if this is related, but right after the error. If I reattempt the first command
files = get_files_by_query session, "title = 'Competitors' and trashed = false"
The results are returned as an Array of Hash objects and not Google::APIClient::Schema::Drive::V2::File objects.
Below are the wrappers used above.
def get_files_by_query session, query
get_files session, {'q' => query}
end
def get_files session, parameters
drive = session.discovered_api("drive", "v2")
result = session.execute(api_method: drive.files.list, parameters: parameters)
if result.status == 200
files = result.data.items
else
puts "An error occurred: #{result.data['error']['message']}"
end
end
Thanks!
More of an FYI since this was addressed in the comments, but the issued that caused this has been fixed in the client library for a while now.
I have a variable in the MATLAB workspace and I want to pass this variable to a function in my GUI.
How do I achieve this task?
You can use the function EVALIN in your GUI to get the value of a variable from the base workspace. The following example extracts the value of the variable A in the base workspace and places that value in the local variable B:
B = evalin('base','A');
You could, for example, have an editable text box in your GUI that allows the user to enter the name of a variable to import from the base workspace. One of your GUI functions could then read the string from the editable text box and attempt to fetch that variable from the base workspace to use in some computation:
varName = get(hEditText,'String'); %# Get the string value from the uicontrol
%# object with handle hEditText
try %# Make an attempt to...
varValue = evalin('base',varName); %# get the value from the base workspace
catch exception %# Catch the exception if the above fails
error(['Variable ''' varName ... %# Throw an error
''' doesn''t exist in workspace.']);
end
You can use SETAPPDATA (in the main workpsace) and GETAPPDATA (in GUI) functions.
If you variable is someMatrix
setappdata(0,'someMatrix',someMatrix) % in the main workspace
someMatrix = getappdata(0,'someMatrix') % in GUI