Local script in button:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game.ReplicatedStorage.FEevents.BanPlayer:FireServer() |
3 | end ) |
Server script in button:
1 | game.ReplicatedStorage.FEevents.BanPlayer.OnServerEvent:Connect( function (player) |
2 | local bayun = Instance.new( "BoolValue" ) |
3 | bayun.Name = script.Parent.Parent.BANPLAYERHOLDER.Text |
4 | bayun.Value = true |
5 | bayun.Parent = game.Workspace.BanishedPlayers.Banned |
6 | game.Players:FindFirstChild(script.Parent.Parent.BANPLAYERHOLDER.Text):Kick( "You have been BANNED for: " ..script.Parent.Parent.BANPLAYERReason.Text) |
7 | end ) |
The FEevent BanPlayer is a RemoteEvent, should it be a different event?
Please mark my answer as the solution :D
Local script:
01 | local ban = game.ReplicatedStorage.BanPlayer --RemoteEvent variable. |
02 |
03 | script.Parent.MouseButton 1 Click:Connect( function () |
04 | local bp = script.Parent.Parent.BANPLAYERHOLDER.Text -- Gui.who is being banned. |
05 | local br = script.Parent.Parent.BANPLAYERReason.Text -- Gui.For what reason they are being banned. |
06 | ban:FireServer(bp ,br) -- Fires with parameter ( player, arg, arg2 ), where player is automatically parsed,arg1 is the banned player,arg2 is the reason to ban player. |
07 | end ) |
08 |
09 | ban.OnClientEvent:connect( function (arg, arg 2 ) --Listener of FireClient(),just an example. |
10 | print (arg, arg 2 ) |
11 |
12 | end ) |
Server script:
01 | local ban = game.ReplicatedStorage.BanPlayer -- Declare variables outside of functions. |
02 |
03 | ban.OnServerEvent:Connect( function (player,arg,arg 2 ) -- Parse arguments player, and variants. |
04 |
05 | local bayun = Instance.new( "BoolValue" ) -- Created BoolValue. |
06 | bayun.Name = arg -- BoolValue.Name = arg(Player who is being banned) |
07 | bayun.Value = true -- Ban = true |
08 | bayun.Parent = game.Workspace.BanishedPlayers.Banned -- Creates a boolvalue in BanishedPlayers.Banned |
09 | print (player, arg, arg 2 ) -- Prints. |
10 | game.Players:FindFirstChild(arg):Kick( "You have been BANNED for: " .. arg 2 ) -- arg is the banned player's name and arg2 is the reason to ban player. |
11 |
12 | local h = Instance.new( "Hint" ) -- A Hint to show the server who has been banned and for what reason. |
13 | h.Text = (arg.. " has been kicked because of : " ..arg 2 ) --Hint.Text ( simple ). |
14 | h.Parent = workspace |
15 | wait( 2 ) |
16 | h.Parent = nil --Destroys Hint. |
17 |
18 | ban:FireClient(player, arg,arg 2 ) -- Explains how a FireClient() works. |
19 |
20 | end ) -- Do not forget to end functions and loops appropriately. |
EDIT : To get more assistance can I get a screenshot of the hierarchical order of your game explorer.