I wrote the code for a GUI and it worked flawlessly in Studio but not in Test/Play mode.
I figured out the problem is the first bit of code: local p = game.Players.Player1.PlayerGui.ScreenGui.PlayerLoadout
But I don't know how to make it accessible to all players instead of just Player1. Help?
Assuming this is in a LocalScript, the LocalPlayer property of Players will work for you:
local p = game.Players.LocalPlayer.PlayerGui.ScreenGui.PlayerLoadout
Otherwise, you'll have to use the PlayerAdded event to make this run for each any every Player:
game.Players.PlayerAdded:connect(function(player) local p = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("PlayerLoadout") end)
game.Players.PlayerAdded:connect(function(player) local p = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("PlayerLoadout") end) local p = game.Players.LocalPlayer.PlayerGui.ScreenGui.PlayerLoadout function onButtonClicked() script.Parent.Parent:TweenPosition(UDim2.new(0.025, 0 , 1, 0)) wait(0.5) p.Visible = true wait(0.2) p:TweenPosition(UDim2.new(0, 0, 0.84, 0)) end script.Parent.MouseButton1Click:connect(onButtonClicked)