I'm working on a game for a friend, and he asked me to make a sprint script. As I didn't want to use an already made one, I attempted to make one myself, which doesn't shoot any errors when I use it, but it does not change the speed. I do not know how to change the FOV either. Please help!
UIS = game:GetService("UserInputService")
function sprint()
local debounce = 1
if debounce then
--make fov
debounce = 0
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24
wait(0.1)
debounce = 1
end
end
function stopsprint()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
game.Players.PlayerAdded:Connect(function(plr)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.KeyCode.LeftShift or input.UserInputType == Enum.KeyCode.RightShift then
sprint()
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.KeyCode.LeftShift or input.UserInputType == Enum.KeyCode.RightShift then
stopsprint()
end
end)
end)

2 comments
Try using remotes to change walkspeed.
posted the working code