Hello, I'm helping someone make their game and I am trying to do the GUI aspect of it.
They told me to make a shop, which I am doing. So what I am trying to do is, when you walk on the part, the GUI will either popup, or slide in. However, when I tried to do either of these, none of them worked, and nothing came in the output and I am not sure what is wrong. Can someone help me?
--Variables
local shop = game.Players.LocalPlayer.PlayerGui.ScreenGui.Background
local part = script.Parent
--main
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.Players.LocalPlayer.PlayerGui.ScreenGui.Background.Visible = true
end
end)
and
--Variables
local shop = game.Players.LocalPlayer.PlayerGui.ScreenGui.Background
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
shop:TweenPosition(UDim2.new(0.5, -125,1.502, 0))
end
end)
Both of these scripts were not executed at the same time. They were executed one at a time and they didn't work.
They were Scripts inside the part that was supposed to be touched by the player and they were the normal script. Can someone tell me where I have gone wrong?

2 comments
On Line 2 with the shop Variable, use "WaitForChild()" for the player Gui and the screen Gui posibly because not all roblox assets are loaded.
@Tizzel40 This isn't a local script... And the gui would open even with no assets loaded