I’d say do a remote function instead.
Well can you help me out, i dont know if any of you understood what i tried to mean but are you able to help?
Firstly, What do u want to do on the server
i have a gui button that can play and stop a siren.
when i execute it i realised only i can hear it
and what im aiming at is for everyone in the server to hear it
Just turn it to server script, I dont see anything on your script may mess it.
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.
No but he wants it to be when a gui is clicked I think.
Yes, a gui that only i can interact whit
which i already scripted
Still wont effect cause it will work when the event fires which is after clicking
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)
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
if you’re able to help i can add you to studio like that you can help out
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…
i turned the local script that is in the gui button into a normal script and it doesnt work
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.
can i ask if you’re able to help out if i add you in studio
Uh weird, I will just shut up
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
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!
I have recently received help from wevetments
and the server script now works