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

How would i make a remote event with this script?

I have a gui that kicks a player, but i want to know who kicked the player so i tried using a local script but then i realized i can't kick on local scripts. I know little about remote events. Can anyone help?

Player = game:service'Players'.LocalPlayer

function click()
	if script.Parent.Parent.TextBox.Text == "" then
	else
	local Reason = script.Parent.Parent.KickReason.Text
	local Kicked =  script.Parent.Parent.TextBox.Text
	game.Workspace.Players:FindFirstChild(Kicked):Kick("You have been kicked, for Reason: "..Reason )
	print(Kicked.." has been kicked by "..Player" For reason: "..Reason)
	end
end
script.Parent.MouseButton1Down:connect(click)

2 comments

0

Have you tried adding a function, where you must put your name in the GUI? It acts as a safety measure as well as a function..

0

Yeah I thought of that, but it may not be that secure, for example someone can falsely put someone else name.

1 answer

✓ Accepted answer

I believe a RemoteFunction is what you're looking for. It allows you to execute server scripts within a local script.

Create a server script and put a RemoteFunction inside. Put that script in the script like this. (makes a lot of sense, lol.)

script.RemoteFunction.OnServerInvoke = function(player)
Player = game:service'Players'.LocalPlayer
script.Parent.MouseButton1Down:connect(function()
    if script.Parent.Parent.TextBox.Text == "" then
    else
    	local Reason = script.Parent.Parent.KickReason.Text
    	local Kicked =  script.Parent.Parent.TextBox.Text
    	game.Workspace.Players:FindFirstChild(Kicked):Kick("You have been kicked for "..Reason)
		print(Kicked.." was kicked by "..Player.Name.. " for "..Reason)
    	end
	end)
end

Then, in a local script, do this.

game.Workspace.Script.RemoteFunction:InvokeServer() --Already passes "player", so no need to do so again

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