Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make a gui pop up when i touch a brick?

and also, if applicable, how could multiple guis pop up when a brick is touched?

script.Parent.Touched:connect(function (hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
Play = game.Players[hit.Parent.Name]
if Play:FindFirstChild("PlayerGui") and not Play.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = Play.PlayerGui
end
end
end)

it is going to be for a shop gui, so once you touch the shop, a menu would pop up where you can buy items, i just want the gui popping up done also, the screenguis name is ShopGui1

2 comments

0

This code doesn't work for you? It looks fine to me.

0

it doesn't work for me :/

2 answers

✓ Accepted answer

You could do this.

local Part = script.Parent

Part.Touched:connect(function(HIT)
	local H = HIT.Parent:FindFirstChild("Humanoid")
	if H then
			local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
			Player.PlayerGui.GUINAME.Frame.Visible = true
	end
end) 


Place it inside a brick. And change "GUINAME.Frame" to Where the gui you want to show is located, I'm sure you can figure out how to modify this.

3 comments

0

it doesn't seem to work for me, does it also work with unions?

0

Send me your entire code and I can try to help you! :)

0

haha apparently the visible tab was checked off, thanks!

does this work?


script.Parent.Touched:connect(function(hit)
	if(hit ~= nil)then
		if(hit.Parent:FindFirstChild("Humanoid") ~= nil)then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			workspace.Shop.ScreenGui:Clone().Parent = player:FindFirstChild("PlayerGui")
		end
	end
end)

1 comment

0

i forgot to mention mine has to have a model called Shop in the workspace and the gui needs to be in shop

This discussion is preserved as it was. New answers, comments, and votes are closed.