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 = Character.Humanoid:LoadAnimation(Anim) 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!
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 = Character.Humanoid:LoadAnimation(Anim) PlayAnim:Play() end) script.Parent.MouseButton1Up:Connect(function(player) local character = player.Character Character.Humanoid.WalkSpeed = 16 Character.Humanoid.JumpPower = 50 PlayAnim:Stop()