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)
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 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.
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)