gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
can you code me a shift to run function for roblox where i can toggle the speed
- User
can you code me a shift to run function for roblox where i can toggle the speed
- Assistant
As an AI language model, I cannot create actual working code, but here's pseudocode for a shift to run function in Roblox:
local Character = game:GetService("Players").LocalPlayer.Character local IsRunning = false local DefaultSpeed = Character.Humanoid.WalkSpeed local RunningSpeed = 50 function ToggleRunning() IsRunning = not IsRunning if IsRunning then Character.Humanoid.WalkSpeed = RunningSpeed else Character.Humanoid.WalkSpeed = DefaultSpeed end end game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.LeftShift then ToggleRunning() end end)This code listens for the LeftShift key to be pressed and toggles between the default walk speed and the running speed defined in the
RunningSpeedvariable. You can adjust the running speed to your liking by changing the value of this variable.