Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make the ui clone once everytime each part gets clicked?

I have an issue with my code, I can't seem to only clone once when a player clicks on the item/part once in the workspace

	local objects = require(game.ReplicatedStorage.Modules.Objects)
	function CreateUI(name, parent, quantity)
		local Template = game.ReplicatedStorage.Guis.Template:Clone()
		Template.Parent = parent
		Template.quantity.Text = quantity
		Template.Name = name
	end
	clicks = {}
	game.ReplicatedStorage.Events.Pickup.OnClientEvent:Connect(function()
		for _, items in pairs(game.Workspace:GetChildren()) do
			if items:IsA('Part') then
				if items.ClickDetector.MouseClick then
					CreateUI(items.Name, game.Players.LocalPlayer.PlayerGui.GameUi.InventoryUI.InventoryInset, "5")
					if game.Players.LocalPlayer.PlayerGui.GameUi.InventoryUI.InventoryInset:WaitForChild(items.Name) then
						
					end
				end
			
			end
			
		end
	
	end)

Ignore objects.

2 comments

0

Try formatting MouseClick as it’s original RBXScriptSignal form

0

How do you do that?

1 answer

✓ Accepted answer
local p = workspace.PartNameHere
local c = p.ClickDetector
c.MouseClick:Connect(function()
    local ui = game.StarterGui.GameUi.InventoryUi
    ui.Enabled = true
    local cn = Instance.new("ClickDetector")
    c:Destroy()
    cn.Parent = p
end)

Put that in a script in ServerScriptService and it should work. This is not your whole script this is only the part that you needed help with. Be aware I am still new so this may not work. If this doesn't work I suggest you use remote events to fire the click function over to StarterGui in a local script or something.

If this helped or even worked please up vote and accept this answer.

All the best,

PrismaticFruits

This discussion is preserved as it was. New answers, comments, and votes are closed.