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.
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