Text doesn't change with serverscript?

How do I make it so that when a player presses a button- the entire server sees the change in UI - not just one player.
I’m using Server Scripts not Local scripts for this yet it still only affects the player who presses it.

It would help if you could show us the script you are using.


script.Parent.MouseButton1Click:Connect(function()
	if game.ServerScriptService.AutoCommends.Disabled then
		script.Parent.Parent.AutoAppsStatus.Text = "Off"
	else
		script.Parent.Parent.AutoAppsStatus.Text = "On"
	end
end)

Don’t use a server script, use a client sided script. Besides, what kind of GUI is this? If this is a GUI in StarterGui, I can assure you only the player will see it, not the entire server. If you want the entire server to see such an action, do FireServer() and then the server does FireAllClients().

Where in my script would I put the FireServer?

In the click event, and then you would have to have a thread for the event in the server, and all other clients need to have a thread for the event too ( to catch the FireAllClients event ), I highly recommend you watch a YouTube tutorial about RemoteEvents.

1 Like

I’ll take a look , thanks.

30 characters

1 Like

I took a look , now my button doesn’t change text at all:
Here are my scripts:


script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireAllClients()
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
	if game.ServerScriptService.AutoCommends.Disabled then
		game.StarterGui.GUI.UI.Main.AutoAppsStatus.Text = "Off"
	else
		game.StarterGui.GUI.UI.Main.AutoAppsStatus.Text = "On"
	end
end)

On script 1 I also tried FireServer()

Use fire all clients on the server.

:FireAllClients() is server only.
Use :FireServer()

What do you mean?

30 characters

I tried that.
Still did not work.
But sure

local script:

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
– Insert another remote event and name it FireAll
– Server script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local TextButton = – wherever ur textbutton/the text u want to change is
game.ReplicatedStorage.FireAll:FireAllClients(TextButton.Text)
end)

– Insert another local script and say

game.ReplicatedStorage.FireAll.OnClientEvent:Connect(function(Text)
– change text whatever u want to do
end)

And I put the local scripts in my button and the ServerScript in ServerScriptService?

no put ur button wherever it came from put the local scripts in starter gui and put the server script in server script service.

Still nothing.

Script 1: (Parent = Button)

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Script 2: (Parent = ServerScriptService)

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local TextButton = game.StarterGui.GUI.UI.Main.ToggleAutoApps
game.ReplicatedStorage.FireAll:FireAllClients(TextButton.Text)
end)

Script 3: (Parent = StarterGui)


game.ReplicatedStorage.FireAll.OnClientEvent:Connect(function(if game.ServerScriptService.AutoCommends.Disabled then
	game.StarterGui.GUI.UI.Main.AutoAppsStatus.Text = "Off" else
	game.StarterGui.GUI.UI.Main.AutoAppsStatus.Text = "On"
end))

Starter Gui will only affect future players who join the game not current. When a player joins the game, starter gui is copied in to the players gui. So for current players, changing starter Gui would do nothing. You will need to change the player gui on each player for the change.

So I edit the PlayerGUI not the GUI itself?

Yes, you should edit the one in PlayerGui instead of the one in StarterGui.

This is my new script:

script.Parent.MouseButton1Click:Connect(function()
	if game.ServerScriptService.AutoCommends.Disabled then
		wait(0.5)
		game.Players.LocalPlayer.PlayerGui.GUI.UI.Main.AutoAppsStatus.Text = "Off"
	else
		wait(0.5)
		game.Players.LocalPlayer.PlayerGui.GUI.UI.Main.AutoAppsStatus.Text = "On"
	end
end)

Should I keep it like that , using LocalPlayer or make use of game.Players:GetPlayers()

@Vong25