local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://125317000639249"
local AnimationTrack
local function getHumanoid()
local character = Player.Character or Player.CharacterAdded:Wait()
return character:FindFirstChildOfClass("Humanoid")
end
local function ensureAnimationTrack()
if not AnimationTrack or not AnimationTrack.Parent then
local humanoid = getHumanoid()
if humanoid then
AnimationTrack = humanoid:LoadAnimation(Animation)
end
end
end
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.C then
ensureAnimationTrack()
if AnimationTrack then
if AnimationTrack.IsPlaying then
AnimationTrack:Stop()
else
AnimationTrack:Play()
end
end
end
end)
-- Recreate AnimationTrack if character respawns
Player.CharacterAdded:Connect(function()
AnimationTrack = nil
end)
this is the code i got so far, i used a little bit ai after i got stuck.
** You are now Level 17! **