How to make when click detector is activated. Server starts alarm

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make when player clicks button (part) alarm sound starts for everybody on server.

  1. What is the issue? Include screenshots / videos if possible!

I don’t know what’s issue, but here is code that I made.

Local script:

local click = workspace.buttons.alarm.ClickDetector

local remotes = game:GetService("ReplicatedStorage").Remotes

local sound = game:GetService("SoundService").alarm

click.MouseClick:Connect(function(plr)
	remotes.AlarmStarted:FireServer(sound)
end)

Server Script

local remotes = game:GetService("ReplicatedStorage").Remotes

local sounds = game:GetService("SoundService")

game.ReplicatedStorage.Remotes.AlarmStarted.OnServerEvent:Connect(function(player, sound)
	sound:Play()
end)

Screen of explorer:

image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to look on Dev forum but I didn’t found how to fix this.

I believe SoundService is local, Move the location of the Sound

On click detectors, the .MouseClick event can be detected from the server. Therefore, a local script and a remote event are not needed.

Try using this one script instead (in a normal script):

local click = workspace.buttons.alarm.ClickDetector

local sound = game:GetService("SoundService").alarm

click.MouseClick:Connect(function(plr)
	sound.Playing = true
end)

Also, To play sounds, do Sound.Playing = true, not Sound:Play().

It does work. But only works locally. It doesn’t work for hole server. It works only for 1 client only

I found solution. I made script inside of ServerScriptService and I moved sound to click part. Now it works. Here is script:

local click = workspace.buttons.alarm.ClickDetector

local sound = click.Parent.alarm

click.MouseClick:Connect(function(plr)
	sound.Playing = true
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.