Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I've been trying to make a script that displays dialog when you step on a brick but it doesnt work?

Asked by
7_c 37
7 years ago

I've been trying to make it so when you touch a brick it displays dialog and then when you touch another brick it removes the current dialog and adds new dialog. Make sense?

Anyways whenever I touch the 2nd brick it works, but when I try to touch the 1st brick again it doesn't work? Any reason why?

P.S: I suck at scripting, and I only know how to make basic scripts

Brick 1:

local deb = false

GUI = script.Parent.TEXT

script.Parent.Touched:connect(function (hit)

if not deb then
deb = true

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
local gui = GUI:Clone()
gui.Name = "Test2"
gui.two.Text = "Roblox1"
gui.Parent = Play.PlayerGui
if Play.PlayerGui:FindFirstChild("Test1") then
Play.PlayerGui.Test1:Remove()



deb = false

end
end
end
end
end)

Brick 2:

local deb = false

GUI = script.Parent.TEXT

script.Parent.Touched:connect(function (hit)

if not deb then
deb = true

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
local gui = GUI:Clone()
gui.Name = "Test1"
gui.two.Text = "Roblox2" 
gui.Parent = Play.PlayerGui
if Play.PlayerGui:FindFirstChild("Test2") then
Play.PlayerGui.Test2:Remove()


deb = false

end
end
end
end
end)

Answer this question