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

How to tween gui for all players at once?

I'm trying to TweenPosition of Gui PlayerGui.GUI.Blue by button using ClickDetector and I wanna do that for all players at once.

Code I'm using:

script.Parent:WaitForChild("ClickDetector")
local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function()
	for i,v in pairs(game.Players:GetPlayers()) do
v.PlayerGui.GUI.Blue:TweenPosition(UDim2.new(0.009, 0, 0.9, 0))
end


end)

Error that shows up in Output:

23:00:04.534 - GUI is not a valid member of PlayerGui

23:00:04.537 - Stack Begin

23:00:04.539 - Script 'Workspace.Button.Script', Line 6

23:00:04.540 - Stack End

(GUI is a member of PlayerGui)

1 comment

0

use wait for child

1 answer

✓ Accepted answer

You cant access to player playerGui from the server script. You need to use RemotEvents

First insert remote event into replicatedstorage and type in your brick script this

local Event = game:GetService("ReplicatedStorage"):WaitForChild("Your Event Name")--Put here your event name
local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function()
	Event:FireAllClients() --Firing all clients 
end)

Now insert a localScript into StarterGui and type another script.

local Event = game:GetService("ReplicatedStorage"):WaitForChild("Your Event Name")--Put here your event name
local Player = game:GetService("Players").LocalPlayer
local Gui = Player.PlayerGui.GUI.Blue

Event.OnClientEvent:Connect(function() --This script will be activated when someone will press the clickdetector
	Gui:TweenPosition(UDim2.new(0.009, 0, 0.9, 0),'Out','Quint',1,true)
end)

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