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

Why does my kill animation play in studio but not in the game?

Asked by 4 years ago

I have a kill script which is set up if you press K, it plays an animation and you die. When I published and tested the game, it only killed me. I don't understand why the animation isn't playing. Can anyone help?

Script:

local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")
local AnimationId = 'rbxassetid://4506927840'
local Debounce = true
local Key = 'K'
local noise = game.SoundService.Snap
UserInputService.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    if Input.KeyCode == Enum.KeyCode[Key] and Debounce == true then
        Debounce = false
        local Animation = Instance.new("Animation")
        Animation.AnimationId = AnimationId
        local LoadAnimation = Humanoid:LoadAnimation(Animation)
        LoadAnimation:Play()
        wait(0.4)       
        noise:Play()
        wait(0.2)   
        LoadAnimation:Destroy()
        Humanoid.Health = 0
        Debounce = true
    end
end)

3 answers

Log in to vote
0
Answered by 4 years ago
'rbxassetid://4506927840' 

Above Needs to be Below

"rbxassetid://4506927840"

Try to read the wiki next time ;/ it's not that hard ;/

0
Answered LOL! HandznLegz 18 — 4y
0
That didn't work. It still worked in studio, but not in the game. I changed it and made sure to publish like 3 times. Nothing changed. Just_Moop 27 — 4y
0
Maybe you should be the one reading the wiki, this is roblox, you can declare a string with single quotes Azure_Kite 885 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Probably the character dies before the animation load try to make the animation object with the ID outside the script and put them in starterCharacter then play it via the script

Log in to vote
0
Answered by 4 years ago

I found the solution. I forgot that the experimental mode no longer works. I shall now use Remote events to update the script so it can work again.

Answer this question