Button not playing effects for anyone else

hi so i rlly need help. i have a local script which makes a button only appear on my screen and none of the other player’s screens. when pressed, it makes an event happen where the lights go out and sounds play and stuff WHICH WORKS GREAT but when playing with other random people, i realized that the sound and stuff are only playing for me. im rlly confused on how would i make it so that only the button part happens for me but the effects happen for everyone

local bright = game.Lighting.bright
local shutoff = script.Parent.Sound
local scare = script.Parent.Sound2
local areas = game.StarterPlayer.StarterPlayerScripts.Regions.Sound
local on = script.Parent.Sound3
local amb = script.Parent.Sound4

local player = game.Players.LocalPlayer

if player.Name == "alexeons" then
    script.Parent.Parent.Enabled = true
end

game.StarterGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
    shutoff:Play()
    amb:Play()
    black.Enabled = true
    bright.Enabled = true
    wait(6)
    scare:Play()
    wait(9)
    amb:Stop()
    black.Enabled = false
    bright.Enabled = false
    on:Play()
end)```
1 Like

Because it is a local script thus the sound is not playing on the server and only the client.
To make the sound play on the server fire a remote event and pick the call up from the server and play the sound from there.

im sorry ive been trying to learn about remote events for like an hour and havent had any luck, i dont know how to use one properly

Remote Events basically provides a way to communicate between the Client(Players) and the server.
There are some things the server cannot detect for example user input so local scripts are used in that case.
In this case, you want so that when you press the button everything occurs on the server.
You could have used server script but you want to check if the player is someone specific , in this case you have to use remote event.

To do the following add a remote event in replicated storage as it is replicated to both server and client

> LOCAL SCRIPT 
> 
> local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent") : Got the remote event
> 
> local player = game.Players.LocalPlayer
> 
> if player.Name == "alexeons" then
>     script.Parent.Disabled = false 
> end
> 
> game.StarterGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
> remoteEvent:FireServer() 
> end) 
> 
> SERVER SCRIPT
> 
> local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent") : Got the remote event
> local bright = game.Lighting.bright
> local shutoff = script.Parent.Sound
> local scare = script.Parent.Sound2
> local areas = game.StarterPlayer.StarterPlayerScripts.Regions.Sound
> local on = script.Parent.Sound3
> local amb = script.Parent.Sound4
> 
> remoteEvent.OnServerEvent:Connect(function()
>     shutoff:Play()
>     amb:Play()
>     black.Enabled = true
>     bright.Enabled = true
>     wait(6)
>     scare:Play()
>     wait(9)
>     amb:Stop()
>     black.Enabled = false
>     bright.Enabled = false
> end)

does not seem to be working. the button appears but nothing happens when clicked.

where is the script and the local script located ?

Try adding print statements to check if the events are firing

script is in serverscriptstorage and local script is in starter gui. where should i add the print statements? also i changed the vairables around a bit in the server script and put the audios in workspace, is that okay?

What is server script storage ?

Put the server script in server script service.
Get reference to the objects you will need and store them in the variable.

Put a print statement after clicked event and also the On server Event.

OOPS i meant server script service

here is my server script:

local bright = game.Lighting.bright
local shutoff = game.workspace.Sound
local scare = game.workspace.Sound2
local areas = game.StarterPlayer.StarterPlayerScripts.Regions.Sound
local on = game.workspace.Sound3
local amb = game.workspace.Sound4


local Remote = game:GetService("ReplicatedStorage").Remote
Remote.OnServerEvent:Connect(function(player) -- Listens out for event
		print(player.Name.." triggered the event to run.")
		shutoff:Play()
		amb:Play()
		black.Enabled = true
		bright.Enabled = true
		wait(6)
		scare:Play()
		wait(9)
		amb:Stop()
		black.Enabled = false
		bright.Enabled = false
		on:Play()
	end)```

When you click does it print out?

no, it does not print out when i click

Add a print statement after Mouse button clicked event and see if that prints something or not.

Can you send the local script?

i added a print statement here, which did not work

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Remote")

local player = game.Players.LocalPlayer

if player.Name == "alexeons" then
	script.Parent.Parent.Enabled = true
end


game.StarterGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
	print("testing")
	remote:FireServer() 
end)

What is script.Parent.Parent.Enabled???

Need a reference depending on what is the script.Parent.Parent

it will be script.Parent.Disabled = false

You’re trying to create a MouseButton1Click event on starterGui instead of the PlayerGui. Your script wouldn’t even detect a click in the first place.

2 Likes

i have the script inside the text button, which is inside the gui so i did script.parent.parent.enabled (which is off) and then that turns it on for me

how would i fix it? im a little confused lol

Could you post a screen shot of your explorer?

image_2021-08-17_011258