GUI will not pop up after hitting part twice or more

Hello. I am currently making a dialog GUI that pops up when you step on a brick, and when the dialog ends, I was to have it pop up again when the player touched the part again if they wanted to play the dialog again. I am currently having trouble with it having to pop up a second time, becasue when I step on the brick again, it does not pop up the dialog UI. Here is my code for the pop up:

local GUI = script.ShopDialogGui 
script.Parent.Touched:connect(function (hit)
 if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
      local plr = game.Players[hit.Parent.Name]
 if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
			GUI:Clone().Parent = plr.PlayerGui
			wait (0.5)
			game.Players.LocalPlayer.PlayerGui.ShopDialogGui.Frame.TextLabel.MainScript.Disabled = false

 end
 end
end)
1 Like

Don’t disable the script. Instead, destroy the frame

The script needs to enabled in order for the script to play at the right time. If I don’t have the script disabled before the player will go to the part, the dialog will play.

I didn’t disable the script, I made it so it wasn’t disabled.

Its because your not destroying the GUI after its in the player. When there’s more then 1 GUI of the same name it may break.

Oh sorry, I didn’t read it carefully. Either remove the part where you check if it exists, or destroy the frame after the player closes the dialog

I told you that the dialog deletes itself when it runs. When the player touches the part is enables a script and makes the UI visible. The Dialog runs itself out and deletes itself.

Found the problem your not defining player as local player = game.Players:FindFirstChild(Hit.Parent.Name) instead your doing game.Players.LocalPlayer.PlayerGui which is no work since its a server script

No, no, no. That part works perfectly fine, it’s just not doing it twice though. Everything is working except for it showing it again after i’ve already touched the part once.

still change game.Players.LocalPlayer.PlayerGui to the player since local player doesent work in server scripts

also try printing the outputs to see where its stopping/not working

As far as I know, the script is not breaking. I just want code to be added on making it so it shows another time.

Here’s a video of what is going on.

I have changed the code, too.

local GUI = script.ShopDialogGui
script.Parent.Touched:connect(function (hit)
 if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
	local plr = game.Players:FindFirstChild(hit.Parent.Name)
 if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
			GUI:Clone().Parent = plr.PlayerGui
			wait (0.5)
			plr.PlayerGui.ShopDialogGui.Frame.TextLabel.MainScript.Disabled = false

 end
 end
end)

try GUI.Frame.TextLabel.MainScript.Disabled = false

orrr instead of cloning the GUI put the GUI in starterGui and in the script do plr.PlayerGui.ShopDialogGui.Enabled = true

Hmm, I’ve decided to do it with a ProximityPrompt.

This was figured out, I decided to do it with a Proximity Prompt instead…