Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

attempt to call a nil value??????

Asked by 1 year ago

Every single time I click ANYWHERE AT ALL in my cart ride game, it pops up with "attempt to call a nil value - Client", and it completely cancels out my tool.activated functions (ive tried removing the tool.activated function btw) I used CTRL + SHIFT + F to look for any click functions or mouse functions that could be causing this, but there is nothing. I don't know why this is happening. I've searched everywhere, and I've checked the server for errors. Someone please help.

0
Try really looking closely at the code and seeing if you made a typo. tonomeow 5 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

It could either mean there's a typographical errros or you didn't use :WaitForChild() in local scripts. Keep in mind that you should use Instance:WaitForChild(Child) instead of Instance:FindFirstChild(Child) or Instance.Child when using local scripts.

This is because local scripts loads faster than the game itself. Meaning when local scripts run, everything in the server like the workspace, the players, GUIs, etc. doesn't exist yet until the server finally loads.

Wrong:

-- local script
local StringValue = workspace.StringValue
print(StringValue.Value)

Correct:

-- local script
local StringValue = workspace:WaitForChild("StringValue") -- pauses the script waits for "StringValue" to exist in the workspace
print(StringValue.Value)
Ad

Answer this question