GUI not changing for all players

So basically I wanted to make the button go inactive for all players in the server and play the tween for the entire server. I tried doing

for i, v in pairs(game.Players:GetPlayers()) do
v.PlayerGUI --and the location of the button
end

but it did not work. This is where I have the script:
image
I really want to avoid people clicking that button over and over since it would break the game obviously.
I also tried creating a remoteevent and firing the server but I didn’t know how to do that.

local tweenservice = game:GetService("TweenService")
script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Active == true then
		script.Parent.Active = false
		tweenservice:Create(script.Parent.UIStroke,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 10, Transparency = 1}):Play()
		tweenservice:Create(script.Parent,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {BackgroundColor3 = Color3.new(1, 1, 1)}):Play()
		game.ReplicatedStorage.Power:FireServer(false)
		wait(10)
		game.ReplicatedStorage.Power:FireServer(true)
	end
end)

script.Parent.MouseEnter:Connect(function()
	if script.Parent.Active == true then
		tweenservice:Create(script.Parent.UIStroke,TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 3.5}):Play()
	end
end)

script.Parent.MouseLeave:Connect(function()
	if script.Parent.Active == true then
		tweenservice:Create(script.Parent.UIStroke,TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 1}):Play()
	end
end)
1 Like

Whenever you make a screengui or surfacegui theres an option thats automatically set in properties called ResetOnSpawn. If you check that off and then set the button visible property to false you should be good.

actually is there a way everyone could see that tween?

if you make it on the server then yea, sure everyone will

Oh yeah I almost forgot, I’ll go try that!

local tweenservice = game:GetService("TweenService")
game.StarterGui.StartupScreen.Button.MouseButton1Click:Connect(function()
	if game.StarterGui.StartupScreen.Button.Active == true then
		game.StarterGui.StartupScreen.Button.Active = false
		tweenservice:Create(game.StarterGui.StartupScreen.Button.UIStroke,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 10, Transparency = 1}):Play()
		tweenservice:Create(game.StarterGui.StartupScreen.Button,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {BackgroundColor3 = Color3.new(1, 1, 1)}):Play()
		game.Workspace.Game.Variables.Power.Value = false
		wait(10)
		game.Workspace.Game.Variables.Power.Value = true
	end
end)

Alright I put the script (not a local script) in the server script storage but it’s not working? Sorry I am not really into scripting.

when did roblox add server script storage?

1 Like

…? I meant ServerScriptStorage I was not paying attention… Thanks for reminding me though.

1 Like

its kinda hard to explain but you are tweening the StarterGui which is the gui that is getting copied to a player’s screen when they join the game which doesnt update as they do play the game

do this instead

local tweenservice = game:GetService("TweenService")
game.StarterGui.StartupScreen.Button.MouseButton1Click:Connect(function()
	if game.StarterGui.StartupScreen.Button.Active == true then
		game.StarterGui.StartupScreen.Button.Active = false
		
		for _, PlayerUI in ipairs(game.Players:GetPlayers()) do
			tweenservice:Create(PlayerUI.StartupScreen.Button.UIStroke,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 10, Transparency = 1}):Play()
			tweenservice:Create(PlayerUI.StartupScreen.Button,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {BackgroundColor3 = Color3.new(1, 1, 1)}):Play()
		end

		game.Workspace.Game.Variables.Power.Value = false
		wait(10)
		game.Workspace.Game.Variables.Power.Value = true
	end
end)

you can’t detect button clicks on the server, however I sent this script here in case you might wanna trigger the tweening by any other way

Just fire a remote to all clients to hide it.

-- Server Side
-- Whenever you want the hide it 
RemoteEvent:FireAllClients()
-- Client Side
RemoteEvent.OnClientEvent:Connect(function()
   -- Hide it here
end)
1 Like
local tweenservice = game:GetService("TweenService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	Player.PlayerGui.StartupScreen.Button.MouseButton1Click:Connect(function()
		if Player.PlayerGui.StartupScreen.Button.Active == true then
			Player.PlayerGui.StartupScreen.Button.Active = false
			tweenservice:Create(Player.PlayerGui.StartupScreen.Button.UIStroke,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 10, Transparency = 1}):Play()
			tweenservice:Create(Player.PlayerGui.StartupScreen.Button,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {BackgroundColor3 = Color3.new(1, 1, 1)}):Play()
			game.Workspace.Game.Variables.Power.Value = false
			task.wait(10)
			game.Workspace.Game.Variables.Power.Value = true
		end
	end)
end)

Here it says he’s tried it, but maybe he didn’t do it right. it’s just better to use remotes. Also why does it have nothing to do with remotes?

1 Like

oh yea youre right lol i am so dumb

2 Likes

Fun fact I actually knew how to do it but for some reason I didn’t want to… Anyway I’ll go do that right away!

1 Like

there’s one small problem. The button doesn’t get clicked. There are no errors though…

sadly, you cant do anything about this than just use the client to detect button clicks as they dont replicate to the server

How does your script look, since you should be handling the button on the client?

what do you mean…? Which script?

You server side and client side

I deleted the one on the server side. I can show you the one on client side though.

local tweenservice = game:GetService("TweenService")
script.Parent.MouseEnter:Connect(function()
	if script.Parent.Active == true then
		tweenservice:Create(script.Parent.UIStroke,TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 3.5}):Play()
	end
end)

script.Parent.MouseLeave:Connect(function()
	if script.Parent.Active == true then
		tweenservice:Create(script.Parent.UIStroke,TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0), {Thickness = 1}):Play()
	end
end)