How do I get this to only give the GUI once until the GUI doesnt exist in the player again?
GUI = script.Parent.ShopGUI:Clone() function Touch(hit) local add = GUI:Clone() human = hit.Parent:FindFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(hit.Parent) add.Parent = player.PlayerGui end script.Parent.Touched:connect(Touch)
Try this, We are using GetPlayerFromCharacter() To go to the person who touched the part, to their player and look inside of their StarterGui to see if ShopGUI exists. If it does then nothing happens, if it doesn't exist then something will happen.
local GUI = script.Parent.ShopGUI:Clone() function Touch(hit) if game.Players.GetPlayerFromCharacter(hit.Parent).StarterGui.ShopGUI == nil then local add = GUI:Clone() human = hit.Parent:FindFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(hit.Parent) add.Parent = player.PlayerGui else print(" ") end end script.Parent.Touched:connect(Touch)
If there's a problem, tell me and I'll fix it.
local ting = 0 -- set a debouncer
GUI = script.Parent.ShopGUI:Clone()
02
03 function Touch(hit) -- when touched
if ting == 0 then -- if debouncer is off then t~~~~~~~~~~~~~~~~~ `` ~~~~~~~~~~~~~~~~~ ing = 1 -- make the debouner on so it cant be activated again 04 local add = GUI:Clone() 05 human = hit.Parent:FindFirstChild("Humanoid") 06 player = game.Players:GetPlayerFromCharacter(hit.Parent) 07 add.Parent = player.PlayerGui 08 end 09 ting = 0 -- reset! end 10 script.Parent.Touched:connect(Touch)