Hello developers,
I got an issue while scripting my game. Let me show my script first.
local function highSpeed(toggle)
local ws
if toggle then ws = 20
else ws = 16
end
for _,player in pairs(playersService:GetPlayers()) do
local character = player.Character
if character then character.Humanoid.WalkSpeed = ws end
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").WalkSpeed = ws
end)
end
playersService.PlayerAdded:Connect(function(plr)
local character = plr.Character
if character then character.Humanoid.WalkSpeed = ws end
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").WalkSpeed = ws
end)
end)
end
So in this function, the ws variable is supposed to change according to the toggle. If the toggle is true, then ws is supposed to be 20, else it is supposed to be 16. It works fine. It changes the walkspeed to 16 when the command is ran with the parameter false. But the issue is, once my walkspeed is 16, If I reset the character, my walkspeed gets back to 20. Any help?
Thanking you in advance,
pranvexploder. ![]()