Ello so I’m trying to make it so that when a player touches a part a gui pops up. However, the gui won’t pop up. I’m new to scripting and I’m still learning everything I’m still a beginner and would really appreciate some help and support!
You want to place the cloned ScreenGui in PlayerGui instead of StarterGui (cuz it wont work when trying to place it in StarterGui).
Use this code:
local Part = script.Parent
local LoadingGui = Part:WaitForChild("Loading")
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player.PlayerGui:FindFirstChild("Loading") then -- if gui already exists in PlayerGui
return -- does not make gui pop up
end
-- Otherwise
local CloneGui = LoadingGui:Clone() -- clones Gui
CloneGui.Parent = player:WaitForChild("PlayerGui") -- places gui in PlayerGui
end
end
end)