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

Why is this RemoteEvent not working? The others do?

Asked by
Kulh 125
6 years ago
Edited 6 years ago

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?

0
Where is the scripts located? Wiscript 622 — 6y
0
In a button, within a gui. (Gui>Frame>Button) Kulh 125 — 6y
0
ScreenGui Kulh 125 — 6y
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. arshad145 392 — 6y
0
im confused? Kulh 125 — 6y

1 answer

Log in to vote
0
Answered by
arshad145 392 Moderation Voter
6 years ago
Edited 6 years ago

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.

0
How do i see a print, just to make sure. If it is "Output" i don't see a print.. Kulh 125 — 6y
0
I'm going to try to remove the BanPlayer event from the folder and have its parent ReplicatedStorage only Kulh 125 — 6y
0
Not working Kulh 125 — 6y
0
SOMEONE?? Kulh 125 — 6y
View all comments (2 more)
0
Omg! Was I high or something yesterday ;-; arshad145 392 — 6y
0
I provided personal assistance and this is solved, therefore mark this thread as answered. arshad145 392 — 6y
Ad

Answer this question