i want to close a UI with a remote even whenever a player clicks the close button, but it wont get the player, how do i get the player? here is my code:
local button = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperendevent = repstorage:WaitForChild("PaperEndEvent")
button.MouseButton1Click:Connect(function(player)
paperendevent:FireClient(player)
end)
Explaining it in a simpler way, as you can see in this image:
What it is doing is sending the signal from the client to the server, and vice versa. I don’t know much about the differences between RemoteEvents and BindableEvents, but that’s what I understand. If I’m wrong, feel free to correct me.
I think the bindable event can be put anywhere, but i will put it inside the script that fires it, or in replicatedstorage, like this:
local button = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperendevent = --path to your bindable event
button.MouseButton1Click:Connect(function(player)
paperendevent:FireClient(player)
end)
local replicatedstore = game:GetService("ReplicatedStorage")
local paperendevent = replicatedstore:WaitForChild("paperendevent")
local player = game.Players.LocalPlayer
paperendevent.Event:Connect(function()
if player.PlayerGui.ScreenGui.Enabled == true then
player.PlayerGui.ScreenGui.Enabled = false
else
return nil
end
end)
here is my script
local button = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperendevent = repstorage:WaitForChild("paperendevent")
button.MouseButton1Click:Connect(function(player)
paperendevent:Fire(player)
end)
yes im clueless i dont know what im doing, never heard of bindable events never used them. doesnt work either so i dont know what to do.
RemoteEvents send signals from the client to the server (and vice versa). BindableEvents can only send signals from client to client (yourself) and server to server.
BindableEvents only have the :Fire() method rather than the context specific methods.
I dont know what you mean with hierarchy, my native language isn’t english so im still learning, i think you mean this:
and i want to achieve whenever a player clicks the close button the UI closes on client side, cause i think if i just put it in a script and say ui.enable = true/false it would do it on all clients since i think scripts are server sided.