So I am making a local sprinting script to make a player go faster when they press "c". When I playtested, I the script wouldn't work. It wouldn't even print. Please help.
Code:
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local walkspeed = player.CharacterAdded:Wait():WaitForChild("Humanoid").WalkSpeed
local replicatedstorage = game:GetService("ReplicatedStorage")
local sprinting = false
mouse.KeyDown:Connect(function(key)
if key == "c" then
sprinting = true
print("sprinting")
walkspeed = walkspeed * 2
end
end)
mouse.KeyUp:Connect(function(key)
if key == "c" then
sprinting = false
print("stopped sprinting")
walkspeed = walkspeed / 2
end
end)

1 comment
Thank you very much