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

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

Asked by 3 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

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)
0
What line is it on? WideSteal321 773 — 3y
0
What with the line 5-7??? naturedat 124 — 3y
0
You're not using debounce correctly, line 18-29. naturedat 124 — 3y
0
Did you set the animation's priority to action? naturedat 124 — 3y

1 answer

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

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.

Ad

Answer this question