I am working on a custom Control Script, containing a local script, a server script, and a remote event (referred to as the variable "r"), it is supposed to operate in a sense that when you press 'w', 'a', 's', or 'd' your character's torso CFrame will move forward/backward according to lookVector, and/or Rotate, here are the scripts so far: Local Script:
local r = game:GetService("ReplicatedStorage"):WaitForChild("Control");
local uis = game:GetService("UserInputService");
local cas = game:GetService("ContextActionService");
uis.MouseIconEnabled = false;
Pause = function() print("p"); end
cas:BindAction("Pause", Pause, true, Enum.KeyCode.P);
uis.InputBegan:connect(function(input)
while table.getn(uis:GetKeysPressed()) > 0x00 do
for i = 0x01, table.getn(uis:GetKeysPressed()) do
r:FireServer(uis:GetKeysPressed()[i].KeyCode);
end
wait();
end
end);
Server Script:
script.Control.Parent = game:GetService("ReplicatedStorage");
local r = game:GetService("ReplicatedStorage"):WaitForChild("Control");
r.OnServerEvent:connect(function(plr, info)
if info == Enum.KeyCode.W then
plr.Character:FindFirstChild("Torso").CFrame =
plr.Character:FindFirstChild("Torso").CFrame +
plr.Character:FindFirstChild("Torso").CFrame.lookVector;
elseif info == Enum.KeyCode.S then
plr.Character:FindFirstChild("Torso").CFrame =
plr.Character:FindFirstChild("Torso").CFrame -
plr.Character:FindFirstChild("Torso").CFrame.lookVector;
elseif info == Enum.KeyCode.A then
plr.Character:FindFirstChild("Torso").CFrame =
plr.Character:FindFirstChild("Torso").CFrame *
CFrame.fromEulerAnglesXYZ(0, 0.15, 0);
elseif info == Enum.KeyCode.D then
plr.Character:FindFirstChild("Torso").CFrame =
plr.Character:FindFirstChild("Torso").CFrame *
CFrame.fromEulerAnglesXYZ(0, -0.15, 0);
elseif info == Enum.KeyCode.P then
end
end)
This works really well, however whenever I continuously press 'w', 'a', 's', and/or 'd', without stopping, the character begins moving extremely fast, which I do not want as the character will spiral out of control due to the speed. If anyone could let me know why they think this is happening, and how they think it could be fixed please let me know. Help would be much appreciated, thanks!

2 comments
Your spacing in the first code block is very odd, and why are those 2 numbers represented in hexadecimal? I know it doesn't have anything to do with your question, but you may want to re-consider those things.
the actual scritps spacing is normal, I just had trouble pasting in the local script as the first 3 lines were really long