-Character Walkspeed! - FIXED -

I am trying to make it so that every second the character walkspeed goes down.

image

while true do

game.StarterPlayer.CharacterWalkSpeed = game.StarterPlayer.CharacterWalkSpeed - 1

wait(1)

end

oh and, forgot to mention,its not decreasing in-game either

so what exactly is the issue here?

the problem is its not going down in game

local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")

while wait(1) do
Humanoid.WalkSpeed = Humanoid.WalkSpeed-1
end
2 Likes

image

--VARIABLES
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

--LOAD
while wait(1) do
Humanoid.WalkSpeed = Humanoid.WalkSpeed-1
end
1 Like

oh, if you’re using a local script, try:

while true do
 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed -= 1
 task.wait(1)
end
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		while task.wait(1) do
			char:WaitForChild("Humanoid").WalkSpeed -= 1
		end
	end)
end)

So, with all of the ones ive tried none affect walk speed

im not using a local, its a normal script

Oh it’s server? Then I’ll have to rewrite it

When will the walkspeed lower, as soon as the player spawns?

yeah bassically so as soon as you spawn in

You can also use a local script in StarterCharacterScripts and do

while wait(1) do
    script.Parent:WaitForChild("Humanoid").WalkSpeed -= 1
end

Actually yeah nevermind, you shouldn’t use a serverscript for that @MysticOrangeLeaf

this here works for me. it also is wrapped in a coroutine so that it doesn’t yield when executed on every player

local function player_added(plr)
	coroutine.wrap(function()
		local character = plr.Character or plr.CharacterAdded:Wait()
		local humanoid = character:WaitForChild("Humanoid")

		while true do
			humanoid.WalkSpeed -= 1
			task.wait(1)
		end
	end)()
end

for _, plr in ipairs(game.Players:GetPlayers()) do
	player_added()
end

game.Players.PlayerAdded:Connect(player_added)