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

Kick event not being received by clicked button?

Asked by 4 years ago
Edited 4 years ago

I have two scripts but with one I have a problem with. Local script:

kick.MouseButton1Click:Connect(function()
    if ParseTarget then
        game.ReplicatedStorage.AdminFireEvent:FireServer(LocalPlayer, "Kick", ParseTarget, reason)
    end
end)

--[[ kick is the button to kick a player, ParseTarget is the inputted target, reason is the inputted reason and LocalPlayer is the localplayer defined.
--]]

Script in serverscriptservice:

game.ReplicatedStorage.AdminFireEvent.OnServerEvent:Connect(function(LocalPlayer, ActionType, ParseTarget, reason)
    if not ParseAdmin(LocalPlayer) then
        LocalPlayer:Kick("Unauthorized Admin Access")
    elseif ParseAdmin(LocalPlayer) then
        print("player is admin")
        if ActionType == "Kick" then
            print("kick successfully received"..reason)
        end
    end
end)

--[[ ParseAdmin is a function that itterates through a table of userids (admins) and ensure the player is one
--]]

However, I do not get a print receiving kick, though I do get a print for player is admin. I'm unsuure what's wrong, please help me.

0
A player is already fired as the first parameter of OnServerEvent, this means that "Kick" is your LocalPlayer,ParseTarget is your ActionType, and so on. zboi082007 270 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

I don't think you need the "LocalPlayer" in line 3 of you localscript, I'm pretty sure when you fire a server event it automatically uses the player that fired the event as the first argument.

Ad

Answer this question