Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to tween gui for all players at once?

Asked by 5 years ago

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)

0
use wait for child greatneil80 2647 — 5y

1 answer

Log in to vote
1
Answered by
HaveASip 494 Moderation Voter
5 years ago

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)
Ad

Answer this question