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

Animation script not working?

Asked by 9 years ago

Hey i want to know what is the error in this script? Its supposed to play an animation when u press k, i tried both in studio, both in game to press the k button but no animation played. Maybe im typing in ID, wrong?

01local player = game.Players.LocalPlayer
02local char = game.Workspace:WaitForChild(player.Name)
03local humanoid = char:WaitForChild("Humanoid")
04local animation = Instance.new("Animation", player)
05animation.AnimationId = "296883490" -- ex http.robloxblahblah
06local animTrack = humanoid:LoadAnimation(animation)
07local uis = game:GetSerice("UserInputService")
08uis.InputBegan:connect(function(key)
09    if key.KeyCode == Enum.KeyCode.K then
10        animTrack:Stop()
11        animTrack:Play()
12    end
13end)

Answer this question