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

animation script breaks apon death?

Asked by 3 years ago

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"

1
Does the script reload when the player dies? I.e is it in a GUI that has ResetOnSpawn to true? the8bitdude11 358 — 3y
0
it did not, thanks! steel_apples 58 — 3y
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 the8bitdude11 358 — 3y
0
thanks steel_apples 58 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question