Speed Boost script not working

I have a ServerScript in ServerScriptService that takes the players speed, and increases it by a value in a folder in the player.

The issue is that the boost is not applied.

Script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + plr:WaitForChild("Folder").NumberValue.Value
		wait(0.1)
		print(char.Humanoid.WalkSpeed)
	end)
end)

How do I fix this?

1 Like

Any error in output ? Or something else

There is no error in the output.

i’m not sure if this works but try using;

tonumber(plr:WaitForChild("Folder").NumberValue.Value)

what part do I replace with this line of code?

just that part with the same words and stuff

function SetupCharacter(plr,char)
	char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + plr:WaitForChild("Folder").NumberValue.Value
	wait(0.1)
	print(char.Humanoid.WalkSpeed)
end

game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	SetupCharacter(plr,char)  -- Initial
	plr.CharacterAdded:Connect(function(char)
		SetupCharacter(plr,char)  -- if they respawn
	end)
end)

This should fix it. whats happening is the character is sometimes already there when the players characteradded connection is made so it doesn’t fire. You will need to do an initial catch of the char from local char = plr.Charcter or plr.CharacterAdded:Wait() then use the characteradded if they reset, die etc

I’ve tried this code, but it does not work.

what did it do? I did have a typo on plr.Character it was plr.Charcter so i edited it to fix

It did not change the WalkSpeed, and printed out 16.

then your value must be set to 0 try doing the same code but in place of

just add a number like 30

this will show you the script is working and then you can figure out the value issue

the value of the NumberValue is set to 3.2

Edit: and the script does work, but the value doesn’t.

i have an idea, how about erase the NumberValue and make it an int value one instead

Decimals don’t work in IntValues if I recall correctly.

very unlikely and desperate but for certain reasons is the script disabled (or a local script if that even happens)

It is enabled, and is a ServerScript.

ok then, correct me if i’m wrong but when your character spawns in, is the value in the folder actually set to an amount instead of being the default 0?

The value in the folder is set to an amount.

i mean how is the folder created or value (it may interfere with the boosting), show the script of it just in case there are flaws since you have stated earlier the code does work except from the value

Found a solution by adding a wait() for a few seconds before attempting to apply the boost.