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

Clone() wont clone the children of the model, why?

I have a model in Server Storage. The model contains simple Parts(Parts/Unions) that contain one part that has a weld to all the other parts. Its a PrimaryPart of the model so I will be able to move the model.

Im trying to Clone the model and weld it on the player, it works. However, when I die (reset for example) and I try to Clone and weld the model again - it wont work. The model it self gets cloned perfectly. But its Children (the parts) wont clone. I just get an empty Model inside the character.

ServerScript:

local helmet = ss.Helmet:Clone()

local p = helmet.Neck  --Acts as a PrimaryPart

  

local w1 = Instance.new("Weld", p)

w1.Name = "HelmetWeld"

  

function SuitUp(plr)

		local char = plr.Character or plr.CharacterAdded:Wait()

		local FindHelmet = char:FindFirstChild("Helmet")

		if not FindHelmet then

		print("lol")  --This runs all the time.

		helmet.Parent = char

		p.CFrame = char.Head.CFrame

		w1.Part0 = p

		w1.Part1 = char.Head

		w1.C0 = CFrame.new(0, -0.012, 0)

		w1.C1 = CFrame.Angles(math.rad(1), math.rad(270), 0)

	end

end

I also have a cooldown in my LocalScript to prevent spam.

Local Script:

hasSuit = false

script.Parent.MouseButton1Click:Connect(function()

	if hasSuit == false then

		remote:FireServer()

		hasSuit = true

	end

end)

1 answer

your script:

 hasSuit = false
    
    script.Parent.MouseButton1Click:Connect(function()
    
    	if hasSuit == false then
    
    		remote:FireServer()
    
    		hasSuit = true
    
    	end
    
    end)

replace with hasSuit = false

script.Parent.MouseButton1Click:Connect(function()

	if not hasSuit then--checks if its false and if its not then it runs the function
	hasSuit = true--makes it true so u cant run the function

		remote:FireServer()
		wait(1)

		hasSuit = false--sets it back to false after 1 second so u can run the function again
		end

	end

end)

2 comments

0

and replace if not FindHelmet then with if FindHelmet then so it looks for it and not that its not there

0

I dont want the player to be able to click the button multiply times. I want him to get the helme and thats it. When he dies you can take a new suit. Also I check to see if theres a helmet inside him to see if I need to give him one or not. If there is no helmet then give him one.

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