Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 13 days ago
Edited 13 days ago

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

local Player = game:GetService("Players").LocalPlayer -- gets the player
local Char = Player.Character or Player.CharacterAdded:Wait() -- gets their character
local Hum = Char:WaitForChild("Humanoid") -- gets the character's humanoid

Hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function(Speed) -- If the walkspeed changed the function fires
    if (Hum.WalkSpeed >= 51) then -- if it's greater than gamepasses can buy it
        local ban = game.ServerScriptService.AntiSpeed.Ban -- sound for added effect
        ban.Play()
        wait(0.584) -- length of the sound
        Player.kick(Player.." your speed is too high! As a result, you were kicked.") -- kick script
    end
end)

I have also tried putting it in a while true do

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

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

1 answer

Log in to vote
1
Answered by 13 days ago
Edited 13 days ago

You have to use:

Player:Kick()
--instead of
Player.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:

game.Players.PlayerAdded:Connect(function(plr)
-- your things
end)
0
u mean function, right? theking48989987 1410 — 13d
0
Well kinda something. CaptainD_veloper 261 — 13d
0
"Kick is not something of the player" incapaxx 2426 — 13d
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. Shinjaa 64 — 13d
View all comments (2 more)
0
Upvoted. wilsonsilva007 341 — 13d
0
Thank you :). CaptainD_veloper 261 — 11d
Ad

Answer this question