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

It keeps Cloning the whole folder inside my character why?

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")

4 comments

0

check line 11 and the issue is with line 29

0

its ok

0

it just cant clone

0

V should hold the helmet and you can clone that ie v:Clone().Parent = player.Character

2 answers

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

2 comments

0

it clones all the helmets

0

Add an if statement if you only want 1 helmet cloned. if v == "CorrectHelmet" then

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)

1 comment

0

Please edit the question

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