my guess is that it's a local script so it cant change/read the values and run an if statement here's the error: pause_and_play_value is not a valid member of ServerStorage|code:
function pause() if game.ServerStorage.pause_and_play_value.Value == "playing" then game.ServerStorage.pause_and_play_value.Value = "paused" while game.ServerStorage.pause_and_play_value.Value == "paused" do wait (0.1) workspace.MusicScript.S1:Pause() workspace.MusicScript.S2:Pause() workspace.MusicScript.S3:Pause() workspace.MusicScript.S4:Pause() workspace.MusicScript.S5:Pause() script.Parent.Image = 'http://www.roblox.com/asset/?id=5167333273' end end if game.ServerStorage.pause_and_play_value.Value == "paused" then end end script.Parent.MouseButton1Click:Connect(pause)
ServerStorage LocalScript . I already see the problem, but I'll explain it to you anyways. ServerStorage is Server only, while Local Scripts focus on the client. You can either solve this by putting the item in ReplicatedStorage or you can use remote events.
Local scripts are for... You know. Local. They can’t access other areas expect for the player.
Local Scripts are used for the local player, they are usually used to fire off REMOTE EVENTS which could be useful in your case. Make a script which will fire an event to change the on and off value!
https://developer.roblox.com/en-us/api-reference/class/RemoteEvent
LocalScript
cannot access the ServerStorage, it is only accessable to Script
/ ServerScripts.
But fortunately, LocalScript
can in fact access ReplicatedStorage
So I recommend you moving pause_and_play
in ReplicatedStorage
You're code should look like this when you moved it:
function pause() if game.ReplicatedStorage.pause_and_play_value.Value == "playing" then game.ReplicatedStorage.pause_and_play_value.Value = "paused" while game.ReplicatedStorage.pause_and_play_value.Value == "paused" do wait (0.1) workspace.MusicScript.S1:Pause() workspace.MusicScript.S2:Pause() workspace.MusicScript.S3:Pause() workspace.MusicScript.S4:Pause() workspace.MusicScript.S5:Pause() script.Parent.Image = 'http://www.roblox.com/asset/?id=5167333273' end end if game.ReplicatedStorage.pause_and_play_value.Value == "paused" then end end script.Parent.MouseButton1Click:Connect(pause)