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

animation script breaks apon death?

this script just stops working once you die. no clue why tho

local player = game.Players.LocalPlayer
local character = player.Character
repeat wait()
	character = player.Character
until character
local hum = character:WaitForChild("Humanoid")
local emote = hum:LoadAnimation(script.Parent.Emote)
playing = false

script.Parent.MouseButton1Click:connect(function()
	if playing == false then
		emote:Play()
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		playing = true
	elseif playing == true then
		emote:Stop()
		hum.WalkSpeed = 30
		hum.JumpPower = 60
		playing = false
	end
end)

its in a textbutton and in that same button theres an animation called "Emote"

4 comments

1

Does the script reload when the player dies? I.e is it in a GUI that has ResetOnSpawn to true?

0

it did not, thanks!

0

ok well, in that case, the issue is that you never re-define the character. Basically, the script is still looking at the old character that died. So you could simply fix this by adding a player.CharacterAdded part that auto updates the character variable

0

thanks

1 answer

i just had to have reset on spawn on. thanks the8bitdude11

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