Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't my script work when a player's walkspeed is too fast?

Asked by
Jexpler 63
5 years ago

I have a local script:

game.Players.LocalPlayer.Character.Humanoid.Changed:Connect(function(value)
    if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed >= 30 then
        script.Parent.WSG.RemoteEvent:FireServer()
    end
end)

Nothing happens. It's not firing the remote event because I tried adding print("Fired") in the regular script.

1
For starters you need to make sure that character exists, if you aren't waiting for character anywhere in your code - chances are it will be nil when your function is set up. You should also run a check on value to make sure it is WalkSpeed, more things change in Humanoid than you realize. Other than that - I don't see anything wrong with this. SummerEquinox 643 — 5y
1
Ah - you may also opt to have your event in a different location. If your event is somewhere inside of player (other than Backpack), it is my understanding that the server cannot reach it. SummerEquinox 643 — 5y
0
Note that hackers can also change their character's part physics instead of changing the WalkSpeed to speed hack hellmatic 1523 — 5y
0
If one of the answerers helped you, please accept their answer. It is considered good manners and shows that you no longer need help. User#21908 42 — 5y

3 answers

Log in to vote
0
Answered by
oftenz 367 Moderation Voter
5 years ago
Edited 5 years ago

I don't understand what you're doing with your code. Humanoid changes lots of times. Why are you listening for the change? Also WalkSpeed likely has a maximum.

There probably is an error causing because the speed is increasing too high. Set a maximum to stop increasing.

0
EDIT: I am not 100% sure of this answer. This is just a recommendation. Correct me if I'm wrong. oftenz 367 — 5y
0
WalkSpeed does not have a cap. When it gets ridiculously high it may cause issues - but that is not what is wrong with his code. You can try this yourself. Go into Studio and run player.Humanoid.WalkSpeed = math.huge. SummerEquinox 643 — 5y
0
The entirety of the script is supposed to kick any player that goes faster than 30 walk speed Jexpler 63 — 5y
0
Where is your RemoteEvent located? SummerEquinox 643 — 5y
View all comments (2 more)
0
Thanks. @Jexpler This is a terrible way of doing that. oftenz 367 — 5y
0
Then what's the better way of doing it? Jexpler 63 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I don't recommend doing the checks on the client. Use the PlayerAdded event and detect from there. It will not prevent a hacker from hacking if you stop their hacking on the client. They can just change it. As for why your current script is not working you can read this. I hope this helps and have a great day scripting!

0
Doing some checks on the client that the server may not be able to check can help stop brainless skids (skid is script kiddie), but for those of experienced exploiters that understand how the scripts work it might be a problem. User#19524 175 — 5y
0
^ User#21908 42 — 5y
0
The best way to prevent the experienced hacker is to not check their walkspeed because angel is correct in her answer. The best way to check is if they have a certain velocity, meaning, if they go a certain distance in a shorter than allowed time, you kick them User#21908 42 — 5y
0
Or whatever it is you do to hackers User#21908 42 — 5y
Log in to vote
0
Answered by
angeI1001 123
5 years ago
local Player = game:GetService("Players").LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")

Hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function(Speed)
    if (Hum.WalkSpeed > 100) then
        print("Wow, that's really fast!")
    end
end)

This has to be checked locally as the walkspeed value does not replicate to the server. But it's also really risky as they can just delete the script even if you hide it, it will still be in their memory.

Hope this helped.

Answer this question