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

GUI Clones, despite told not to?

Asked by 8 years ago

So. I've got a script which is meant to detect if you already have a GUI in your PlayerGui, but if you don't it clones. It doesn't do that.

local debounce = false
function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 
if player.PlayerGui:FindFirstChild("OfficerGUI") == nil then
game.ServerStorage.OfficerGUI:clone().Parent = player.PlayerGui
end
wait(5)
debounce = false
end
end

script.Parent.Touched:connect(onTouch)

Answer this question