I dont understand remote events

Since my first reply seems to have been ignored, I’ll give it another shot with your specific case.

|Local Script|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("SoundEvent")

local Sound = --put sound here
local function Process(State)
    if not State then
        Sound:Play()
    else
        Sound:Stop()
    end
end

local function OnClick()
    Remote:FireServer()
end

script.Parent.MouseButton1Down:Connect(OnClick)
Remote.OnClientEvent:Connect(Process)
|Server Script|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent")
Remote.Name = "SoundEvent"
Remote.Parent = ReplicatedStorage

local State = false
local function Process(Player)
    if Player.UserId == 000000 then --change the 0s to your UserId
        if not State then
            State = true
            Remote:FireAllClients(true)
        else
            State = false
            Remote:FireAllClients(false)
        end
    end
end

Remote.OnServerEvent:Connect(Process)

When a player clicks the button, the server will check if you were the one that clicked, otherwise the server won’t process the request.

If you are the one that clicked, it will make all the clients play the sound.

2 Likes

No but he wants it to be when a gui is clicked I think.

1 Like

Yes, a gui that only i can interact whit

which i already scripted

1 Like

Still wont effect cause it will work when the event fires which is after clicking

1 Like

I will explain my goal

  • create a gui button that only i can use (already done)
  • make the gui button be able to play and stop an audio which is a siren (done)
  • make other players be able to hear it instead of just me (current problem)
1 Like

The script you have right now you can turn it into server script it will not effect anything as long as you dont use stuff that is only client side, like LocalPlayer

1 Like

if you’re able to help i can add you to studio like that you can help out

1 Like

Cant he just make his own local into server script because its appear for him only + there is nothing that can effect the script or mess with it, it is more simple than yours…

1 Like

i turned the local script that is in the gui button into a normal script and it doesnt work

1 Like

His local script is not compatible on the server and even if it did work, that’s the worst possible way to solve the issue.

1 Like

can i ask if you’re able to help out if i add you in studio

1 Like

Uh weird, I will just shut up :frowning:

1 Like

Yes, you may add me to the place.

Edit:
For those who were wondering, the code in this reply was used to solve the issue

2 Likes

Remember to ask these kind of questions when you have researched on YouTube, Dev Forum, or Dev Hub.

Here is a link I found on RemoteEvents. I hope it helps! Custom Events and Callbacks | Documentation - Roblox Creator Hub

Have a great day!

1 Like

I have recently received help from wevetments
and the server script now works

1 Like

Then put @wevetments post as the solution so that everyone knows that this is already solved.

Ok so I’ve just tried sending a sound location through remote event it worked perfect, you told me that I cant…

Replied to myself accidentally

@xxibadrxx
I said objects cannot be sent through remotes. You didn’t make it clear what you meant exactly by “location” so I assumed you were sending the reference to the object.

Objects created on the client cannot be seen by the server, so the reference will be nil.
You can send objects as long as it exists on the server.

Just to clarify what I meant,

You cannot send objects over remotes. If the object exists on both client and server with the same reference, the reference will not be nil.

If the object is created on the server and deleted by the client, the reference will be nil

In the case of the OP, the sounds exists on the clients, so it will return nil on the server.

Basically what you said, but this method seems inefficient to me. You can save a few bytes sent between the client and server by using the method I provided.

https://devforum.roblox.com/t/network-hit-sending-objects-as-remoteevent-arguments/19123/