Speed script not working!

my speed script won’t work!
it won’t increase my speed!
and it also won’t increase my leaderstats speed value!
script:

local player = game.Players:GetPlayers()

for i, v in pairs(player) do
	if v.Character then
		v.Character.Humanoid.Speed += 1
		
		player.leaderstats.Speed.Value += 1
	end
	
end

any feedbacks ty btw(sorry for my bad typing)

Where is the script located? And especially, is it a normal script or a LocalScript?

its a normal script its in serverscriptservice!

Your script is most likely throwing an error here and stopping. The variable is called WalkSpeed not “Speed”

1 Like

i tryed it but none of it increased my speed, my leaderstats script and my walk speed dint increased hm.
what i tryed:

local player = game.Players:GetPlayers()

for i, v in pairs(player) do
	if v.Character then
		v.Character.Humanoid.WalkSpeed += 1

		player.leaderstats.Speed.Value += 1
	end

end

Where there any errors/comments that ended up appearing in your output console? We should be able to use that to figure out what the issue may be.

Uhh, I would try putting that as a localscript in StarterCharacterScripts. I may be wrong.

1 Like

I’m a little rusty on my Roblox Lua, so I apologize in advance. But you could try that, although you will have the leaderstat issue (must be server-sided), so you would need to fire a remote event in that case which isn’t the most secure thing for data (or so I’ve heard/believe).

Edit: you could do it the other way around for changing the Humanoid properties if that is the issue here. Although I would first see if anything pops up in the output console, so we can determine what the problem is.

2 Likes

dint worked, uh i might try using the remote event for it but idk if it will work!

I believe I know what your issue is. I did a quick test in Studio and found that the problem may be related to your variable or for loop.

Your character may not be completely loaded in yet, so if this is the only code in your script then it is running before it can establish a player. Meaning you need to find a way to hault your code, so players can load in.

Since this is server-sided, a better option might be to use the PlayerAdded built in event.

game.Players.PlayerAdded:Connect(function()
    -- code here
end)

It is possible to put in either StarterPlayerScripts or StarterCharacterScripts, as a LocalScript, but once transformed into LocalScript, the code will change to detect a few things… Here is a little sample:

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

Players.PlayerAdded:Connect(function()
    local Humanoid = Character:FindFirstChildOfClass(”Humanoid”)
    if (Humanoid) then
        Humanoid.WalkSpeed += 1
    end
end)
1 Like

i tryed this:
it worked!!!

game.ReplicatedStorage.Remotes.givespeed.OnServerEvent:Connect(function(player)
	while wait(1) do
			if player.Character then
player.Character.Humanoid.WalkSpeed += 1
			player.leaderstats.Speed.Value += 1
			end
	end
end)

local script:


game.ReplicatedStorage.Remotes.givespeed:FireServer()

ty for ur feedback, u also helped me for it!

1 Like

use task.wait() as it’s better than wait().

task.wait() has a faster delay than wait()

1 Like

and i used the remote evnent , it works it gives me every second 1 speed!

well, is it better to do remote event or playeradded idk??

Glad you found a solution! For best practice I would try to use the PlayerAdded event and not have the client fire immediately to the server for stuff. I also would not add a wait() in the beginning of your code because that is also not a good practice.

1 Like

playeradded as exploiters can easily exploit the remotes

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.