Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why cant i access ServerStorage with a local script?

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)

4 answers

✓ Accepted answer

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.

1 comment

0

oops..sorry

Local scripts are for... You know. Local. They can’t access other areas expect for the player.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.