Can Anyone help Me With My Script?

Hello ! i would like to add a run animation 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)
4 Likes

So just an animation that plays when you run

2 Likes
local Anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation("Put your animation path")
Anim:Play()

2 Likes

Research before u post

2 Likes

I forgot to say it, but I’d like animation to work on mobile because when I do it, it doesn’t work.

2 Likes

I forgot to say it, but I’d like animation to work on mobile because when I do it, it doesn’t work.

2 Likes

This will work perfectly with any device if im correct

2 Likes

i’ve done every steps but it doesn’t work

1 Like

i am confused by what you mean dosn’t work on mobile as it should be replicated to any device i have modifed your code with the roblox docs code and left the reference below

script.Parent.Activated:Connect(function()
	local animationTrack = game.Players.LocalPlayer.character.humanoid:LoadAnimation(animation path eg script:WaitForChild("animation"))

	if script.Parent.Text == "Sprint" then
		script.Parent.Text = "Walk"
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
		animationTrack:Play()
	else
		script.Parent.Text = "Sprint"
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
		animationTrack:Play()
	end
end)

best of luck

I did not specify that when I play my game on pc and I press the shift key there is the sprint animation that plays and when I am on mobile and I press the sprint button it works but I will want to who has sprint animation

i am sorry but i dont quite understand the question could you please rephrase it the part in bafled by is

what exactly do you want does the animation not work or do you want to select certain players who can use the sprint animation i am sorry i dont understand

I’d like animation to work for mobile players too

it should unless your useing a seperate script for mobile players. by that i mean do you have a seperate script for when the shift button is pressed on mobile if so copy the script for pc to that one