I’m trying to make a sprinting mechanic, where when you hold left shift, your character runs faster. I tried doing this with a while loop and printing if they were sprinting, but it didn’t work… Please help.
local Script:
local UIS = game:GetService("UserInputService")
local RP = game:GetService("ReplicatedStorage")
local Event = RP:WaitForChild("SprintingEvent")
local Sprinting = false
UIS.InputBegan:Connect(function(input, typing)
if typing then return end
while Sprinting == true do
wait()
if input.KeyCode == Enum.KeyCode.LeftShift then
print("Sprinting!")
Event:FireServer()
end
end
end)
Server:
local RP = game:GetService("ReplicatedStorage")
local Event = RP:WaitForChild("SprintingEvent")
Event.OnServerEvent:Connect(function(player)
print("Sprinting!")
end)