My touch part wont open the ui

Hi i need help with an undetected error which cause’s my Gui not to open i tried different ways yet nothing still changed, here is the code:

And this :

as you can see when i do touch the part it wont open and does not show any errors in the output, here is an image in where i did turn off the Gui so when the player hits it it opens:

I haven’t figured it out yet i would appreciate if anyone could help.

4 Likes

First, try removing Hum, as it isn’t used, it might be searching for Hum and failing to do so, making an error and breaking your code.
Second, try adding print(“Touched part”) on the touched function, then try touching the part and see if it prints in the console.
Third, what you are displaying is a billboard gui, a typeo f gui that only displays on objects, not on the player’s screen. Check if your gui is visible, adjust the values to have it outside the block and enable on top overlay.

Hoep this helps!

1 Like

Instead of putting the touched event in the function, move it outside of the function:


not:

local function OpenGuis()
    TouchPart1.Touched:Connect(function(hit)

    end)
end

this:

local function OpenGuis(hit)

end
TouchPart1.Touched:Connect(function(hit)
    OpenGuis(hit)
end)

I would also recommend to set the always on top to true.


You also forgot a crucial line to see if there is a humanoid:
you just did:

local Hum = hit.Parent:FindFirstChild("Humanoid")

but you need an if statement to see if there is actually a humanoid:

local Hum = hit.Parent:FindFirstChild("Humanoid")
if Hum then
1 Like

Thank you for responding, i will try it out and see if it works and if it does not i will update you.

First of all, why is your Touched event inside of a function? The OpenGuis() serves no purpose.

Second, a better way to determine if a player touched the part is to check for the player itself

TouchPart1.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		-- open gui
	end
end)

I don’t think this would work, try this:

--// Put all your Parts, Guis, and TouchParts above!
local function OpenGuis(BlockTouched)
    local Hum = hit.Parent:FindFirstChild("Humanoid")
    if Hum then
        script.Parent.Egg1.GuiPart.BillboardGui.Enabled = true
    end
end

TouchPart1.Touched:Connect(function(hit)
    OpenGuis(hit)
end)

I hope this helps.

1 Like

You haven’t set the Adornee for the BillboardGui. This tells the BillboardGui what to display over.

Tried it and still failed idk why, its just kinda annoying trying to figure 1 thing out for about 2 hrs now.

2 Likes