GUI Not Cloning?

Hey Devforumers!

My script isn’t working. I’m actually very confused on this since it will open the first time when ClickDetector.MouseClick is fired, but once the gui clone is deleted it does not re-clone and Tween open the cloned gui.

Here is the code:

local Gui

script.Parent.ClickDetector.MouseClick:Connect(function(plrClicked)
	if plrClicked.PlayerGui:FindFirstChild("CheckInGuiClone") then
		Gui = plrClicked.PlayerGui:FindFirstChild("CheckInGuiClone")
	else
		Gui = plrClicked.PlayerGui.CheckInGui:Clone()
        Gui.Parent = plrClicked.PlayerGui
	    Gui.Name = "CheckInGuiClone"
	end
	
    -- TS = TweenService
	TS:Create(Gui.Frame, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut), {Size = UDim2.new(0.805,0,0.831,0)}):Play()
	wait(0.5)
	Gui = nil
end)
1 Like

What part of the script exactly is not working?

That’s the problem. I can’t seem to fix it.

When i do that i usually do something like

CD.MouseClick:Connect(function(plr)
    Gui:Clone().Parent = PlayerGui
end)

I’m gonna check your script again and try to see if i find something odd

1 Like

Ok my last reply was a bit off the tracks but i just read your script again and i don’t know why it doesn’t work, seem all right to me.

1 Like

The problem with your script is that it can insert an infinite number of GUIs into the PlayerGui since it does that every time you click.

EDIT: What I’m trying to do is check for if it exists and then clone a new one if the GUI doesn’t exist.

Yes, i am aware of that problem, but that was just an example.

So the problem probably is in the part that detects if there is a CheckInGuiClone, because the part that clones it seems to be right

1 Like

I also think the error is in here. :FindFirstChild() doesn’t return a true/false. For some reason, it returns false the very first time but after that it just appears to return nil which stops it from working. There is no error output concerning this script at all.

That was my guess too, nothing else seems to have a chance to be wrong.

1 Like

Code Review is not for broken code. Please use Scripting Support if your code is broken and you are requesting for help on fixing it. Read category guidelines before posting threads. I’ve recategorised this thread accordingly.

1 Like

The problem is your not setting the cloned gui’s parent.
you have to do: plrClicked.PlayerGui not PlayerGui

plrClicked returns the player who clicked… I’m not sure what you mean.

Wait nvm I didn’t read the whole script my bad.

1 Like

you could just put the Gui properties inside the else because you don’t need to rename it the same thing if the if statement works.

Yea, I already did that after posting this, sorry I’ll update the OP code.

Maybe this will help.

local Gui

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if player:WaitForChild("PlayerGui"):FindFirstChild("CheckInGuiClone") then
		Gui = player:WaitForChild("PlayerGui"):FindFirstChild("CheckInGuiClone")
	else
		Gui = plrClicked.PlayerGui.CheckInGui:Clone()
        Gui.Parent = plrClicked.PlayerGui
	    Gui.Name = "CheckInGuiClone"
	end
	
    -- TS = TweenService
	TS:Create(Gui.Frame, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut), {Size = UDim2.new(0.805,0,0.831,0)}):Play()
	wait(0.5)
	Gui = nil
end)

[/quote]

Thanks! I’ll try this out ASAP.

EDIT: @YXFrosty Nope, it still doesn’t work. :frowning:

The problem is that you used the tween service after the statement that clones the gui into the player, the error is that it can’t find the gui since it’s destroyed and it’s considered a nil instance.

So if I simply change

TS:Create(Gui.Frame, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut), {Size = UDim2.new(0.805,0,0.831,0)}):Play()

to this

TS:Create(plrClicked.PlayerGui.CheckInGuiClone.Frame, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut), {Size = UDim2.new(0.805,0,0.831,0)}):Play()

it should work?