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

This script only works in studio. The error states that ShopButton is not a member of player gui?

for i,v in pairs(game:GetService("Players"):GetChildren()) do
	v.PlayerGui:WaitForChild("ShopButton").Frame:TweenPosition(UDim2.new(0.397,0,1.1,0))
end

5 comments

0

is ShopButton a ScreenGui?

0

Is this a LocalScript or Sever Script? Server can’t edit PlayerGui.

0

Also, you shouldn’t be using Players:GetChildren() but use Players:GetPlayers().

0

It's because your script is a server script and your game is Filtering Enabled. Use remove events and use :FireAllClients then tween the gui.

0

thanks

2 answers

###That script of yours should work perfectly fine. It can only error if you have something other than a Player object residing in the Players service. Only Player objects should be there.

###You used Instance:GetChildren() on the Players service, when you should be using Players:GetPlayers(). This exclusively returns players and only players.

###If this is a LocalScript, this won’t work since you’re trying to edit the PlayerGui of another player. This is a thing to prevent exploiters from maliciously creating GuiObjects inside a player.

###If this is a server Script, this wouldn’t work either, since the server can not access PlayerGui. So what can you do? Seems like what you want to accomplish won’t work...

###Just kidding! I’ll use a RemoteEvent and it should work.

-- server Script under ServerScriptService

local remote = Instance.new"RemoteEvent"
remote.Name = "TweenAllGuis"
remote.Parent = game:GetService"ReplicatedStorage"

wait(.1) -- So the remote event has time to listen for OnClientEvent, else will error since the remote’s event wasn’t connected to a function.

for _, v in pairs(game:GetService("Players"):GetPlayers()) do
    remote:FireClient(v)
end

###Now for the client code!

--LocalScript
local rep = game:GetService"ReplicatedStorage"
local plr = game:GetService("Players").LocalPlayer

rep:WaitForChild("TweenAllGuis").OnClientEvent:Connect(function()
    plr:WaitForChild("PlayerGui").ShopGui.Frame:TweenPosition(


    --TweenPosition code here. 
    
)

end)

You don't use a WaitForChild for a GUI, add WaitForChild to .Frame

1 comment

0

This should be a comment.

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