Hi, I am a new scripter, I created my first game not long ago and it was only for PC. I wanted to try to insert commands for mobile players (mechanics in my game: crouch, sprint) But to sprint the script doesn't work, I don't understand why but it certainly has to do with the fact that the image button is in one Gui and the script for sprinting in another. I could very well use an event but the problem is that my sprint is linked to a bar that downloads with a TweetSize showing the player how much you have left at any given moment. Could anyone help me? (Roblox shows me no errors)
SPRINT BAR SCRIPT (NAME: "MobileSprintScript")
--// VARIABLE \--
local UIS = game:GetService('UserInputService') local m = game.Players.LocalPlayer:GetMouse() local mm = game.StarterGui.CrouchGui.ActivateSprint local Bar = script.Parent:WaitForChild('SprintMobile'):WaitForChild(('Bar')) local player = game.Players.LocalPlayer local NormalWalkSpeed = 10 local SprintWalkSpeed = 20 local ii = 10 local running = false repeat wait() until game.Players.LocalPlayer.Character local character = player.Character
--// FUNCTIONS \--
mm.KeyDown:connect(function(key, gameProcessed) if key and gameProcessed == false then character.Humanoid.WalkSpeed = SprintWalkSpeed running = true while ii > 0 and running do ii = ii - 0.27 Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
mm.KeyDown:connect(function(key, gameProcessed) if key and gameProcessed == false then character.Humanoid.WalkSpeed = NormalWalkSpeed running = false while ii < 10 and not running do ii = ii + .08 Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)

3 comments
Mate, you are using :GetMouse on a player service.
a one sec i forgor the .LocalPlayer
lol, fixed.