Hello Developers,
I would be very grateful if you could help me with my most recent issue.
Basically, (in the code I have included), I fire a remoteEvent to the client, then change walkspeed, and then print a debug statement.
Both the print statements either side of the walkspeed line output correctly with no other errors in either the console in-game or output window in Roblox Studio.
I would be incredibly grateful if anyone could help me with this.
local slowInformBoostEvent = boostFolder:WaitForChild("SlowInform") for index, player in pairs(game.Players:GetPlayers()) do if player.Status.Value == true then if player.Alive.Value == true then if player.Murderer.Value == false then slowInformBoostEvent:FireClient(player) player.Character.Humanoid.WalkSpeed = 4 print("WalkSpeed should have changed!") end end end end
Thanks,
Anthony
EDIT: Apologies, I've forgot to add some extra context which I imagine would be useful. This code snippet is inside of a function called executeSlowBoost(), so Players should indeed me in the game (sorry - my fault for not specifying). I have even printed the name of each player who's humanoid walkspeed I am changing (to verify I am indeed getting the correct players as expected). In case it matters, I'm using a server script.
I am really confused because I don't understand how this not working.
Side Note: When I join the game and try to run a command from the server console log:
workspace.[TESTPLAYERNAME].Humanoid.WalkSpeed = 4
This also doesn't produce any errors, HOWEVER it too does not work.
Hello, Anthony!
The only thing I see with your script is that it is being run as soon as the script is loaded, when there are no players in the game. There are various ways to fix it, and it varies from case to case the best one.
Add a wait. If you want to change the walkspeed after some time has passed, adding a wait before the for loop will work. Note that it will only happen once, and if no player is in the game, noone will be affected.
Put it inside a loop. Putting it inside a loop will make it run lots of times, just don't forget the wait
It would be nice to have some more context on what this is exactly for.
Re-reading your question, it seems like the code is running when there are players in game, as you said the print is being output to console, however I don't see any errors anywhere else other than what I mentioned. Something that could be happening is the walk speed being changed/reverted by some other script.
If this answers your question, please mark it as the Accepted answer
.