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

Could I have some help with a script that automatically kicks someone if their speed changes?

Asked by 6 years ago
Edited 6 years ago

So here is the portion of my anti-cheat that has walkspeed

01local Player = game:GetService("Players").LocalPlayer -- gets the player
02local Char = Player.Character or Player.CharacterAdded:Wait() -- gets their character
03local Hum = Char:WaitForChild("Humanoid") -- gets the character's humanoid
04 
05Hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function(Speed) -- If the walkspeed changed the function fires
06    if (Hum.WalkSpeed >= 51) then -- if it's greater than gamepasses can buy it
07        local ban = game.ServerScriptService.AntiSpeed.Ban -- sound for added effect
08        ban.Play()
09        wait(0.584) -- length of the sound
10        Player.kick(Player.." your speed is too high! As a result, you were kicked.") -- kick script
11    end
12end)

I have also tried putting it in a while true do

01while true do
02    Hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function(Speed)
03    if (Hum.WalkSpeed >= 51) then
04        local ban = game.ServerScriptService.AntiSpeed.Ban
05        ban.Play()
06        wait(0.584)
07        Player.kick(Player.." your speed is too high! As a result you were kicked.")
08     end
09 end)
10end

If anyone could help that would be highly appreciated. This is in a normal script put in ServerScriptStorage. FE is off.

0
Player.kick has to be Player:Kick(Player.." your speed is too high! As a result, you were kicked.") Kurcha 33 — 6y
0
Thanks! I just realised I did the kick wrong! Post it as an answer and I can get you the reputation! AidanTES 36 — 6y
0
Player.kick has to be Player:Kick(Player.." your speed is too high! As a result, you were kicked.") Kurcha 33 — 6y
0
I'll just test it in game and then if it works then I will accept the answer! AidanTES 36 — 6y
View all comments (2 more)
0
Wait, I see the problem. You cant get local player from a server side script. CaptainD_veloper 290 — 6y
0
oh could you fix it then? AidanTES 36 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You have to use:

1Player:Kick()
2--instead of
3Player.Kick()

This is because Kick is not something of the player, but an action. And you cannot get local player from server script. Use this:

1game.Players.PlayerAdded:Connect(function(plr)
2-- your things
3end)
0
u mean function, right? theking48989987 2147 — 6y
0
Well kinda something. CaptainD_veloper 290 — 6y
0
"Kick is not something of the player" User#24403 69 — 6y
0
Why does this have one down vote? I'm going to upvote it because it shouldn't have a downvote at all, what he's explaining clearly makes sense. User#21998 0 — 6y
View all comments (2 more)
0
Upvoted. wilsonsilva007 373 — 6y
0
Thank you :). CaptainD_veloper 290 — 6y
Ad

Answer this question