Still have questions? Join our Discord server and get real time help.
1

# How do I make this sprint script compatible on mobile devices?

Edited 8 days ago

Hey everyone! This is my first question on this forum, so sorry if anything is wrong or in the wrong format.

So, I have this thing in my game which allows you to sprint with the press of the shift button. It also plays an different animation while running.

Heres the full script, being parented in StarterCharacterScripts

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 35
Character.Humanoid.JumpPower = 65
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5686974800"
PlayAnim:Play()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
Character.Humanoid.JumpPower = 50
PlayAnim:Stop()
end
end)


Is there anyway I can program a mobile button to activate some variation of this script when being held down? If you need any more info to fix my problem, please ask!

-1

put this is a gui button

script.Parent.MouseButton1Down:Connect(function(player)
local character = player.Character
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 35
Character.Humanoid.JumpPower = 65
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5686974800"
PlayAnim:Play()
end)
script.Parent.MouseButton1Up:Connect(function(player)
local character = player.Character
Character.Humanoid.WalkSpeed = 16
Character.Humanoid.JumpPower = 50
PlayAnim:Stop()


0
there a couple errors in there but i guess you could figure it out catsalt29 57 — 8d
0
The animation part doesnt work, but the sprinting does! Thanks a bunch man. 2_dew 7 — 8d
0
no problem catsalt29 57 — 5d