I made a shop for an rpg in roblox and I can open it and close it, but after I close it, it won't open again and says "Already have GUI." My shop script it

button = script.Parent

function onTouch(part)
	if part.Parent:FindFirstChild("Humanoid") ~= nil then
		local player = Game.Players:GetPlayerFromCharacter(part.Parent)
		if player ~= nil then
			local GUI = Game.ReplicatedStorage:FindFirstChild(script.Parent.ShopGUI.Value)
			local AlreadyHaveGUI = player.PlayerGui:FindFirstChild(script.Parent.ShopGUI.Value)
			if AlreadyHaveGUI == nil then
			GUI:Clone().Parent = player.PlayerGui
			else print("Already have GUI!")
			end
		end
	else print("Humanoid not found!")
	end
end

button.Touched:connect(onTouch)

and my close script is

function close()
script.Parent.Parent.Parent:Remove()
end

script.Parent.MouseButton1Click:connect(close)

5 comments

0

Remove is depreciated, use :Destroy(). Then, see if it works.

0

I'll try it

0

It didn't work

0

Is there anything else I can try?

0

Nevermind I just needed to make it a normal script