local player = game.Players.LocalPlayer
local Char = player.Humanoid
local hum = player.Humanoid --This is where im errored at!
local LiftingAnimation = script.LiftingAnimation
local LiftingAnimationTrack = hum:LoadAnimation(LiftingAnimation)
local Item = script.Parent
Item.Mouse.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
local LiftingAnimationTrack = hum:LoadAnimation(LiftingAnimation)
LiftingAnimationTrack:Play()
local leaderstats = player.leaderstats
local Coinstat = leaderstats and leaderstats:FindFirstChild("Coins")
if Coinstat then
Coinstat.Value = Coinstat.Value + 1
end
end)
end)
Try char.Humanoid
or char:WaitForChild('Humanoid')
i got errored on that to its weird.
I got confused by the fact you capitalized this variable unlike the others; You can either change char
to Char
or local Char
to local char
. Iâd recommend the second for consistency.
local hum = player.Humanoid --you're referencing to LocalPlayer.Humanoid
change it to
local hum = char:WaitForChild("Humanoid")
While you are correct, thereâs more to this than just that. See above for more information.
testing right to see if it work i reply back if it works
player.Character.Humanoid
should work well
Index nill with (âHumanoidâ) it doesnt work
Ill try that and reply back when done.
18:16:22.203 Players.24kslxckz.Backpack.Weight.LocalScript:2: attempt to index nil with âHumanoidâ - Client - LocalScript:2
18:16:22.203 Players.24kslxckz.Backpack.Weight.LocalScript:2: attempt to index nil with âHumanoidâ - Client - LocalScript:2 doesnt work
local player = game.Players.LocalPlayer
local Char = player.Character
local hum = Char:WaitForChild("Humanoid") --This is where im errored at!
local LiftingAnimation = script.LiftingAnimation
local LiftingAnimationTrack = hum:LoadAnimation(LiftingAnimation)
local Item = script.Parent
Item.Mouse.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
local LiftingAnimationTrack = hum:LoadAnimation(LiftingAnimation)
LiftingAnimationTrack:Play()
local leaderstats = player.leaderstats
local Coinstat = leaderstats and leaderstats:FindFirstChild("Coins")
if Coinstat then
Coinstat.Value = goldStat.Value + 1
end
end)
end)
I will see if it will workk.
wait a sec.
didnt work, i tried it.
lol does not work keep erroring at Humanoid.
This should work. If it doesnt idk. lol.
i tried it exactly like that.
didnt work.
What is the error?? Shouldnât be doing that.
18:18:26.176 Players.24kslxckz.Backpack.Weight.LocalScript:2: attempt to index nil with âHumanoidâ - Client - LocalScript:2
will do it rn ill reply back. when done