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

Kick script is kicking myself?

Asked by 3 years ago

I have an admin GUI stored in server storage, to keep it safe from exploiters. When a player joins, my system figures out the roles, then clones it into my gui. In that admin GUI, there is a simple kick script. (The event is in the GUI) ~~~~~~~~~~~~~~~~~

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plrName, Reason, returnPlr) plrName = tostring(plrName) Reason = tostring(Reason) local Success, Error = pcall(function() local plrID = game.Players:GetUserIdFromNameAsync(plrName)

    local plr = game.Players:GetPlayerByUserId(plrID)
    if plr then
        print(plr.Name)


        plr:Kick(Reason)
        script.Parent.Callback:FireClient(returnPlr, "Successfully kicked "..plrName)
    else
        script.Parent.Callback:FireClient(returnPlr, "Invalid")
    end
end)
if not Success then

    script.Parent.Callback:FireClient(returnPlr, "Error | Devs Check Console")
    error(Error)
end

end) ~~~~~~~~~~~~~~~~

What the event returns is the player's name and reason. These all return the correct things. But no matter what I do, I cannot kick another player. It kicks me for an unspecified reason. I came with no errors, it returns the plrname and reason correctly. What am I doing wrong?

Thanks in advance

Signed - Cheslin23t

3 answers

Log in to vote
0
Answered by 3 years ago

It may not work because the sever, even though it can read server storage, it does not run from server storage, try switching to server script service and it may work.

0
The cloning is in server script service, the script is ran from a admin's player gui. I bring the player name and reason from the local script, then the server will kick them. cheslin23t 4 — 3y
0
Are you using free models / plugins, if so, either delete or disable one of them, or you may set the wrong code on remote event or function. tamasjonas 62 — 3y
0
lmao no. cheslin23t 4 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Your script is not safe from exploiters.

0
Well he just said that he stored it in server storage tamasjonas 62 — 3y
0
Sorry, this is not an answer, and is only cloned from server storage if an admin joins. Also I would like the answer to my question please, thanks :) cheslin23t 4 — 3y
0
just because its in the server storage doesnt mean its safe WINDOWS10XPRO 438 — 3y
0
dont user a bindable event or a remote event or remote function or bindable function, exploiters can spy on them. WINDOWS10XPRO 438 — 3y
Log in to vote
0
Answered by 3 years ago

None of those answers answered. I forgot to read the docs! If firing from the client, when getting it from the server, it also returns the player who sent it

Answer this question