I am trying to make a GUI spawner, when the player clicks the part it turns red and says who is spawning, I am trying to check if the player has x out the gui so another player can click the spawner again. The code is inside a part in Workspace.

local spawner = script.Parent
local cd = spawner:WaitForChild('ClickDetector')
local status = spawner:WaitForChild('TextGui'):WaitForChild('Status')
local GUI = script.Parent:WaitForChild('DemoGui')

local clicked = false

cd.MouseClick:Connect(function(player)
	if clicked then return end
	clicked = true
	spawner.BrickColor = BrickColor.new('Bright red')
	status.Text = player.Name.. ' is currently spawning...'
	local playerGui = player.PlayerGui
	if playerGui:FindFirstChild(GUI.Name) == nil then
		local clone = GUI:Clone()
		clone.Parent = playerGui
		clone.Client.Disabled = false
	end
	repeat wait() until playerGui:FindFirstChild(GUI.Name) == nil
	clicked = false
	spawner.BrickColor = BrickColor.new('Bright green')
	status.Text = 'Click to Spawn'
end)

3 comments

0

There are 5 things to know about this. 1:Read my bio. 2:Read my bio already! 3:COME ON JUST READ MY BIO! 4:WHY WON'T YOU READ MY BIO? 5:HOW HARD IS IT TO READ MY BIO??????????

0

Thank you! I fixed it.

0

Hahahahaha