RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make it so mobile users can run aswell with a button on the right hand side"
-- local script local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local player = game.Players.LocalPlayer local runButton = script.Parent.RunButton -- assuming the button is a sibling of the script player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") local camera = game.Workspace.CurrentCamera local runSound = Instance.new("Sound", character:WaitForChild("HumanoidRootPart")) runSound.SoundId = "rbxassetid://360202811" runSound.Looped = true local normalSpeed = 14 local sprintSpeed = 18.5 local normalFOV = 70 local sprintFOV = 90 local sprinting = false local function onShiftDown() if not sprinting then sprinting = true humanoid.WalkSpeed = sprintSpeed local tweenInfo = TweenInfo.new(0.5) local tween = TweenService:Create(camera, tweenInfo, {FieldOfView = sprintFOV}) tween:Play() runSound:Play() end end local function onShiftUp() if sprinting then sprinting = false humanoid.WalkSpeed = normalSpeed local tweenInfo = TweenInfo.new(0.5) local tween = TweenService:Create(camera, tweenInfo, {FieldOfView = normalFOV}) tween:Play() runSound:Stop() end end if camera.CameraType == Enum.CameraType.Custom then UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then onShiftDown() end end) UserInputService.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then onShiftUp() end end) runButton.MouseButton1Down:Connect(onShiftDown) runButton.MouseButton1Up:Connect(onShiftUp) end end)