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

[Repub] why is my anticheat not working?, gives really sus error.

Asked by 3 years ago

Why Is my Code not working? This fires an remote event:

while wait(0.05) do
    local Char = script.Parent
    local Speed = Char.Humanoid.WalkSpeed
    local Tbl = {}
    table.insert(Tbl, Char.Name)
    table.insert(Tbl, Speed)
    game.ReplicatedStorage.AntiCheatLab:FireServer(Tbl)
end

And this is the Code that recieves it:

local Replicate = game.ReplicatedStorage.AntiCheatLab
Replicate.OnServerEvent:Connect(function(tbl)
    local charName = tbl[1] -- Error is here, line 3
    local speedVal = tbl[2]
    local PlLoad = game.Players:WaitForChild(charName) 
    local ChLoad = game.Workspace:WaitForChild(charName)
    local CharObj = game.Workspace:WaitForChild(charName)
    if CharObj.Humanoid.WalkSpeed ~= speedVal then
        game.Players[charName]:Kick("===")
    end
end)

Error 1 is not a valid member of Player "Players.Ferrarimami" - Server - Script:3

0
This is my 3rd Reupload, because no one is answering to old threads Ferrarimami 120 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

By default, the first argument to OnServerEvent is the player that called :FireServer(arg) on this RemoteEvent. There is no way to disable this. That's why the first argument of OnServerEvent is the player. The solution is to add another parameter behind tbl for the player.

0
Thank you! Ferrarimami 120 — 3y
Ad

Answer this question