Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Kick event not being received by clicked button?

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.

1 comment

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.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.