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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your 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)
0
and replace if not FindHelmet then with if FindHelmet then so it looks for it and not that its not there Gameplayer365247v2 1055 — 5y
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. HeyItzDanniee 252 — 5y
Ad

Answer this question