Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I fix this? Animation and Tool the error I'm getting is attempt to index nil with 'Parent'

First I would like to say I apologize for what I done earlier, Second I have a error with my script, the error is attempt to index nil with 'Parent'

local tool = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
while character.Parent == nil do
	character.AncestryChanged:Wait()
end
local leaderstats = player.leaderstats
local cooldown = 2
local ready = true
local humanoid = character:WaitForChild("Humanoid")
local animation = tool.Animation
local animationTrack = humanoid:LoadAnimation(animation)


tool.Activated:Connect(function()
	
	if ready == true then
	animationTrack:Play()
	--animationTrack.Looped = true
	print("Animation Played!")
	leaderstats.Strength.Value = leaderstats.Strength.Value + 1
	print("Strength Added!")
	ready = false
	animationTrack:Stop()
	wait(cooldown)
	print("Cooldown Done!")
	ready = true
	end
end)

4 comments

0

What line is it on?

0

What with the line 5-7???

0

You're not using debounce correctly, line 18-29.

0

Did you set the animation's priority to action?

1 answer

✓ Accepted answer

I think you are referring to the lines 5-7. Character is a property of LocalPlayer - it has no Parent, so the lines 5-7 aren't needed. Also, give more information regarding your problem in future questions, please.

This discussion is preserved as it was. New answers, comments, and votes are closed.