Hello ! i would like to add a animation di in my script so anyone can help me for that ?
here is the script
script.Parent.Activated:Connect(function()
if script.Parent.Text == "Sprint" then
script.Parent.Text = "Walk"
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
else
script.Parent.Text = "Sprint"
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
end)
U can play an animation in your script by loading one like this
local Animation = -- Create an animation or define one that already exists.
local AnimationTrack = Humanoid.Animator:LoadAnimation(Animation)
To play it you can just call
AnimationTrack:Play()
AnimationTrack | Documentation - Roblox Creator Hub
Also I’d suggest defining variables to improve readability for example
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')