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

[Urgent!] Why is this error popping up when I try to use an animation tool?

Error: Players.TickTockTheory.Backpack.Sit Up.LocalScript:3: attempt to index field 'Character' (a nil value)

anime = script.Parent.name.Value

hum = game.Players.LocalPlayer.Character.Humanoid


script.Parent.Activated:connect(function(m)
			local anim_pushup = hum:LoadAnimation(script.Parent.meditate)
			anim_pushup:Play()
end)


It doesnt seem to work on a public server, but only in studio...

1 comment

0

I have a tool that requires no handle. It has this local script it in it and my animation that I want to run when I click.

1 answer

✓ Accepted answer

The Character does not spawn immediately. When the LocalScript first starts, the Character has not spawned, so game.Players.LocalPlayer.Character is nil, as the error is telling you.

You have to wait for the character to spawn. Something like the following should work for you:

local character = player.Character or player.CharacterAdded:Wait()

1 comment

0

Thanks!

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