Make GUI Appear/Unpaper when you step on/off a brick?

I want to know how to make something like that to use for one of my games.

I just need the script I already have my test GUI it’s called (TestScreenGui)

4 Likes

You could use .Touched and .TouchedEnded, however I really don’t recommend it due to the large amount of inaccuracies. If you’re open to using resources provided by the community, you could probably try Zone+ which I linked to this post. It’s much more reliable and uses RayCasting and Region3 to get the most accurate results possible.

When the player is added or removed, you can try sending a remote event to the players which are in the area, and then you could send another remote event which closes the UI when the player left.

Try This :

function GiveGui(hit)
	n = hit.Parent.Name
	p = game.Players:FindFirstChild(n)
	if not p.PlayerGui:FindFirstChild("TestScreenGui") then
		local gui = script.TestScreenGui:Clone()
		gui.Parent = p.PlayerGui
	end
end

function DeleteGui(hit)
	n = hit.Parent.Name
	p = game.Players:FindFirstChild(n)
	if p.PlayerGui:FindFirstChild("TestScreenGui") then
		local gui = p.PlayerGui:FindFirstChild("TestScreenGui")
		gui:Destroy()
	end
end

script.Parent.Touched:connect(GiveGui)
script.Parent.TouchEnded:Connect(DeleteGui)

it seems to work but when I step on the brick, it dose it very fast like it appears but at the same time it also unpapers when I move around

I recommend using Region3 or Magnitude but they both involve loops which may toll the server.

Well, this is what you are looking for :

local debounce = false

function getPlayer(humanoid) 
	local players = game.Players:children() 
	for i = 1, #players do 
		if players[i].Character.Humanoid == humanoid then return players[i] end 
	end 
	return nil 
end 

function onTouch(part) 

	local human = part.Parent:findFirstChild("Humanoid") 
	if (human ~= nil) and debounce == false then
		debounce = true

		local player = getPlayer(human) 

		if (player == nil) then return end 

		script.Parent:clone().Parent = player.PlayerGui
		wait(3)
		debounce = false
		player.PlayerGui.TestScreenGui:remove()
		wait()
		debounce = false
		wait(5)
	end
end


script.Parent.Parent.Touched:connect(onTouch)

ok I tested it to make sure it works, and it dose thanks it works fine

1 Like