Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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.

0
Try formatting MouseClick as it’s original RBXScriptSignal form Ziffixture 6913 — 4y
0
How do you do that? MrTrayLot 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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

Ad

Answer this question