Help My GUI Script Won't work!

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!

the script:

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)

You’re defining loading and then checking it for loading

It’s visible ahalkhklsahlashsas characters

Have You Tried @BabyNinjaTime Code Yet?

1 Like

Ah it worked thank you so much I didn’t even know playergui was a thing so I learned appreciate it

1 Like

You are very welcome! Glad you learned something new