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 comments
Answered LOL!
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.
Maybe you should be the one reading the wiki, this is roblox, you can declare a string with single quotes