I have been trying to make a run script for scripting practices and so far I have created a working run script. However, I want to know if this code is an acceptable format or does it need some improvement. Can someone please check through my code and tell me what I need to improve on and change?
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Running = 50
local Walking = 16
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid") --WaitForChild("Humanoid") works too.
if Humanoid then
Humanoid.WalkSpeed = Running
end
end
end)
UserInputService.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid") --WaitForChild("Humanoid") works too.
if Humanoid then
Humanoid.WalkSpeed = Walking
end
end
end)

5 comments
if I would create a run script, I would do exactaly that
This is scripting helpers, not code review
its still helping scripts
code review is not the same as helping with an issue
theres a section in discord for code review