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

Why is this RemoteEvent not working? The others do?

Local script in button:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.FEevents.BanPlayer:FireServer()
end)

Server script in button:

game.ReplicatedStorage.FEevents.BanPlayer.OnServerEvent:Connect(function(player)
local bayun = Instance.new("BoolValue")
bayun.Name = script.Parent.Parent.BANPLAYERHOLDER.Text
bayun.Value = true
bayun.Parent = game.Workspace.BanishedPlayers.Banned
game.Players:FindFirstChild(script.Parent.Parent.BANPLAYERHOLDER.Text):Kick("You have been BANNED for: "..script.Parent.Parent.BANPLAYERReason.Text)
end)

The FEevent BanPlayer is a RemoteEvent, should it be a different event?

5 comments

0

Where is the scripts located?

0

In a button, within a gui. (Gui>Frame>Button)

0

ScreenGui

0

When you state :FireServer( player) -- parameter must be player , but in the OnServerEvent, there is no need for parameter player as it has already been passed.Try to print(player.Name) you will see, if it has passed it or not.

0

im confused?

1 answer

✓ Accepted answer

Please mark my answer as the solution :D

Local script:

local ban = game.ReplicatedStorage.BanPlayer--RemoteEvent variable.

script.Parent.MouseButton1Click:Connect(function()
local bp = script.Parent.Parent.BANPLAYERHOLDER.Text -- Gui.who is being banned.
local br = script.Parent.Parent.BANPLAYERReason.Text -- Gui.For what reason they are being banned.
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.
end)

ban.OnClientEvent:connect(function(arg, arg2)--Listener of FireClient(),just an example.
	print(arg, arg2)
	
end)

Server script:

local ban = game.ReplicatedStorage.BanPlayer-- Declare variables outside of functions.

ban.OnServerEvent:Connect(function(player,arg,arg2) -- Parse arguments player, and variants.

local bayun = Instance.new("BoolValue") -- Created BoolValue.
bayun.Name = arg -- BoolValue.Name = arg(Player who is being banned)
bayun.Value = true -- Ban = true
bayun.Parent = game.Workspace.BanishedPlayers.Banned -- Creates a boolvalue in BanishedPlayers.Banned
print(player, arg, arg2) -- Prints.
game.Players:FindFirstChild(arg):Kick("You have been BANNED for: " .. arg2)-- arg is the banned player's name and arg2 is the reason to ban player.

local h = Instance.new("Hint") -- A Hint to show the server who has been banned and for what reason.
h.Text = (arg.." has been kicked because of : "..arg2)--Hint.Text ( simple ).
h.Parent = workspace
wait(2)
h.Parent = nil --Destroys Hint.

ban:FireClient(player, arg,arg2) -- Explains how a FireClient() works.

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.

6 comments

0

How do i see a print, just to make sure. If it is "Output" i don't see a print..

0

I'm going to try to remove the BanPlayer event from the folder and have its parent ReplicatedStorage only

0

Not working

0

SOMEONE??

0

Omg! Was I high or something yesterday ;-;

0

I provided personal assistance and this is solved, therefore mark this thread as answered.

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