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

It keeps Cloning the whole folder inside my character why?

Asked by 6 years ago

Instead of the single object (Accessory) being cloned inside the character in workspace its the whole folder gets cloned into the character.INFO the actual folder the model is being cloned from is saved in the player in a folder called 'HelmetStorage' saved in the players storage folder, why?

player = game.Players.LocalPlayer

--

local Enabled = false

function UpdateInventory()
    if Enabled == false then
        Enabled = true
        script.Parent.ScrollingFrame.Visible = true
        script.Parent.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,20*#player.Inventory.HelmetStorage:children())
        script.Parent.ScrollingFrame:ClearAllChildren()
        for i,v in pairs(player.Inventory.HelmetStorage:GetChildren()) do
            local Place = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Inventory.HelmetStorage
            local Obj1 = Instance.new('TextButton',script.Parent.ScrollingFrame)

            Obj1.Size = UDim2.new(1,-12,0,20)
            Obj1.Position = UDim2.new(0,0,0,20*i-20)
            Obj1.BackgroundTransparency = 0
            Obj1.FontSize = 'Size24'
            Obj1.Text = v.Name
            Obj1.Font = 'Cartoon'
            Obj1.ZIndex = 7
            Obj1.TextColor3 = Color3.new(255, 255, 255)
            Obj1.TextXAlignment = 'Left'

            Obj1.MouseButton1Down:connect(function()

                player.Inventory.HelmetStorage:Clone(v).Parent = player.Character
                warn("PRESSEDD")

            end)
        end
    else
        Enabled = false
    end
end

script.Parent.Parent.Parent.Parent.BottomFrame1.CHARACTER.Button.MouseButton1Down:connect(function()
    UpdateInventory()
end)

player.Inventory.HelmetStorage.Changed:connect(function()
    if Enabled == false then Enabled = true UpdateInventory() end
    if Enabled == true then Enabled = false UpdateInventory() end
end)

I think the problem is this line

                player.Inventory.HelmetStorage:Clone(v).Parent = player.Character
                warn("PRESSEDD")
0
check line 11 and the issue is with line 29 User#5423 17 — 6y
0
its ok aleandroblingo -35 — 6y
0
it just cant clone aleandroblingo -35 — 6y
0
V should hold the helmet and you can clone that ie v:Clone().Parent = player.Character User#5423 17 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Yeah, the problem is that line. player.Inventory.HelmetStorage:Clone(v).Parent = player.Character

"HelmetStorage:Clone()" is the whole storage being cloned. Putting v in the function Clone() does nothing.

Since you're already using a For loop and iterating through all the items, the helmet you want is v

for i,v in pairs(player.Inventory.HelmetStorage:GetChildren()) do
    local helmetClone = v:Clone()

    helmetClone.Parent = player.Character
end
0
it clones all the helmets aleandroblingo -35 — 6y
0
Add an if statement if you only want 1 helmet cloned. `if v == "CorrectHelmet" then` MooMooThalahlah 421 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I think im close but it says its not a valid member ect UGHH

player = game.Players.LocalPlayer

--

local Enabled = false

function UpdateInventory()
    if Enabled == false then
        Enabled = true
        script.Parent.ScrollingFrame.Visible = true
        script.Parent.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,20*#player.Inventory.HelmetStorage:children())
        script.Parent.ScrollingFrame:ClearAllChildren()
        for i,v in pairs(player.Inventory.HelmetStorage:GetChildren()) do
            warn("GOT CHILDREN")
            local Client = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
            local Place = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Inventory.HelmetStorage
            local Obj1 = Instance.new('TextButton',script.Parent.ScrollingFrame)
            warn(Client.Name)

            Obj1.Size = UDim2.new(1,-12,0,20)
            Obj1.Position = UDim2.new(0,0,0,20*i-20)
            Obj1.BackgroundTransparency = 0
            Obj1.FontSize = 'Size24'
            Obj1.Text = v.Name
            Obj1.Font = 'Cartoon'
            Obj1.ZIndex = 6
            Obj1.TextColor3 = Color3.new(255, 255, 255)
            Obj1.TextXAlignment = 'Left'

            Obj1.MouseButton1Down:connect(function()
                Client.Inventory.HelmetStorage(v.Name):Clone().Parent = player.Character
                warn("CLONED")
            end)
        end
    else
        Enabled = false
    end
end

script.Parent.Parent.Parent.Parent.BottomFrame1.CHARACTER.Button.MouseButton1Down:connect(function()
    UpdateInventory()
end)

player.Inventory.HelmetStorage.Changed:connect(function()
    if Enabled == false then Enabled = true UpdateInventory() end
    if Enabled == true then Enabled = false UpdateInventory() end
end)
0
Please edit the question User#5423 17 — 6y

Answer this question