Change player walk speed using script

i made a script to change players walkspeed.

local debounce = 0
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

if debounce == 0 then
	if script.Parent.Value == "SkyForge" then
	    hum.WalkSpeed += 8
	end
	debounce = 1
end

the script above is not working. Note: The value is changing, The Walkspeed is set to the default (16).

2 Likes

@NetheriteMc_Q I dont really know what your script does, but here’s a fixed one.

local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()

local value = script.Parent.Value
local humanoid = Character:WaitForChild("Humanoid")

local debounce = 0
local debounceTime = 3

value.Changed:Connect(function()
	if value.Value == "SkyForge" and debounce == 0 then
		humanoid.WalkSpeed += 8 -- amount of speed added
		debounce = 1
	end
	
	wait(debounceTime)
	debounce = 0
end)

the debounce is made so the script does not run more than twice. i am trying to make the player walk faster depending on the value

1 Like

You can try this


local players = game:GetService("Players")

local function ChangeWalkSpeed(Player)
	if script.Parent.Value == "SkyForge" then
		Player.CharacterAdded:Connect(function(Character)
			local Humanoid = Character:WaitForChild("Humanoid")
			Humanoid.WalkSpeed += 8
		end)
	end
end

players.PlayerAdded:Connect(ChangeWalkSpeed)




Make sure the StrValue is the parent of this serverScript

1 Like
local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()

local value = script.Parent.Value
local humanoid = Character:WaitForChild("Humanoid")

local debounce = 0

value.Changed:Connect(function()
	if value.Value == "SkyForge" and debounce < 3 then
		humanoid.WalkSpeed += 8 -- amount of speed added
		debounce += 1
	end

end)
1 Like

this a local script. not a server script

1 Like

@NetheriteMc_Q, here’s a new script.

local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()

local value = script.Parent.Value
local humanoid = Character:WaitForChild("Humanoid")

local count = 0
local maxCount = 1

changed = value.Changed:Connect(function()
	if value.Value == "SkyForge" and count <= maxCount then
		humanoid.WalkSpeed += 8 -- amount of speed added
		count += 1
	end
	if count == maxCount then
		changed:Disconnect()
	end
end)
1 Like