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

I am confused about "attempt to call a nil value," what does it mean?

Asked by 4 years ago

I barely know what this means, I know its a problem with tool.Activated:Connect(toolActivated) but I'm not sure how to fix it. I know I need to change "toolActivated" to something but I'm not sure what. Does anyone have an idea of what I change it to? The main issue is that this script sometimes works but half the time it says nil value and it doesn't work.

01local sound = script.Parent.Handle:WaitForChild("Sound")
02local beam = script.Parent.Handle.Attachment:WaitForChild("Beam")
03local tool = script.Parent
04local player = tool.Parent.Parent
05local chargesound = script.Parent.Handle:WaitForChild("ChargeSound")
06 
07local debounce = false
08 
09repeat wait(1) until player.Character
10 
11local character = player.Character
12local humanoid = character:WaitForChild("Humanoid")
13 
14-- first animation
15 
View all 63 lines...
0
toolActivated is nil Leamir 3138 — 4y
0
I know but what do I change to fix that Pyro_dood 31 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

toolActivated is in another event, meaning that it doesn't exist for things outside of that event, try putting the toolActivated event outside of the event, also using :Stop() on an animation when it is not already playing does not result in an error if that's why it is not outside of the event.

Ad

Answer this question