So in this code:
script.Parent.Touching.Touched:Connect(function(hit)
if not deb then
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local plrGui = plr:WaitForChild("PlayerGui")
local gui = plrGui:FindFirstChild("ExchangeGui")
deb = true
if gui == nil then
local clone = script.ExchangeGui:Clone()
clone.Parent = plrGui
wait(1)
deb = false
elseif gui ~= nil then
warn("Player still has gui")
deb = false
end
end
end
end)
You get a GUI if you touch it but if you already have a GUI then you don’t get one. When I got the warn statement, I was confused because in explorer there wasn’t a GUI.
So should I change the if statement?
print(not not gui) -- prints true even though I don't have the gui anymore
Here is the code for the GUI:
local remote = game.ReplicatedStorage.Remotes.ExchangeCurrency
for i, ui in pairs(script.Parent:GetChildren()) do
if ui.ClassName == "TextButton" then
ui.Activated:Connect(function()
remote:FireServer(ui.Name)
script.Parent.Parent:Destroy() -- script.Parent.Parent is the gui
end)
end
end
script.Parent.Parent.Exit.Activated:Connect(function()
script.Parent.Parent:Destroy() -- script.Parent.Parent is the gui
end)