I have developed a localscript in StarterPlayerScripts and a script in ServerScriptService.
The purpose of these scrips is to add sprinting when the player presses LeftControl.
Here is my code. It is not too many lines so do not worry.
StarterPlayerScripts LocalScript
local uis = game:GetService("UserInputService")
local toggleSprintEvent = game.ReplicatedStorage:WaitForChild("ToggleSprint")
uis.InputBegan:Connect(function(key, processed)
if processed then return end
if key.KeyCode == Enum.KeyCode.LeftControl then
toggleSprintEvent:FireServer(true)
end
end)
uis.InputEnded:Connect(function(key, processed)
if processed then return end
if key.KeyCode == Enum.KeyCode.LeftControl then
toggleSprintEvent:FireServer(false)
end
end)
SeverScriptService Script
local toggleSprintEvent = game.ReplicatedStorage:WaitForChild("ToggleSprint")
toggleSprintEvent.OnServerEvent:Connect(function(player, turnOnSprrint)
local char = player.Character
if not char:FindFirstChild("Humanoid") then return end
if turnOnSprrint == true then
char:FindFirstChild("Humanoid").WalkSpeed = 50
else
char:FindFirstChild("Humanoid").WalkSpeed = 16
end
end)
Please help!!

4 comments
I mean Left Control as in the key. Thanks for asking so that i can clarify for anyone else who helps!
I tested your code and it works perfectly fine for me. Check if you put in a remote event or remote function. You should be using a remote event under the replicated storage.
Haha wow I didnt even noticed I forgot that man. Thank you so much for reminding, I was going crazy.
Np, brother!