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

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

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

'rbxassetid://4506927840' 

Above Needs to be Below

"rbxassetid://4506927840"

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

3 comments

0

Answered LOL!

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.

0

Maybe you should be the one reading the wiki, this is roblox, you can declare a string with single quotes

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

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.

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