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

:clone() function breaks with other players?

Asked by 4 years ago
Edited 4 years ago

I made a script inside a touched part which imports another script into the character from serverscriptservice. Pretty much the Script clones items from server storage and welds it to the player, however the touched part puts the script inside the player but the script ends up not working if another player has stepped on the part too, and it wont reclone what was in server storage I'm not sure how to fix this because it doesn't have any errors in output. If you know how to fix it being able to clone multiple times into other people please help. Script:

local Limb = game.ServerStorage.Parts.Rarm:Clone()
local Limb2 = game.ServerStorage.Parts.Larm:Clone()
local Limb3 = game.ServerStorage.Parts.Lleg:Clone()
local Limb4 = game.ServerStorage.Parts.Rleg:Clone()
local Body = game.ServerStorage.Parts.Body:Clone()
local Face = game.ServerStorage.Parts.Face:Clone()
    local plr = script.Parent
    local hum = plr.Humanoid
    local children = plr:GetChildren()
    for i=1, #children do
        local instance = children[i]
        if (not instance:IsA("MeshPart")) then
            plr.Bool.Value = true
            local A0 = Limb3:Clone()
            A0.Parent = plr
            A0.Weld.Part1 = plr["Left Leg"]
            A0.Spread.Disabled = false
            wait(0.5)
            local A1 = Limb4:Clone()
            A1.Parent = plr
            A1.Weld.Part1 = plr["Right Leg"]
            A1.Spread.Disabled = false
            wait(1.5)
            local A2 = Body:Clone()
            A2.Parent = plr
            A2.Weld.Part1 = plr["Torso"]
            A2.Spread.Disabled = false
            wait(1.5)
            local A3 = Limb:Clone()
            Limb.Parent = plr
            Limb.Weld.Part1 = plr["Right Arm"]
            Limb.Spread.Disabled = false
            wait(0.5)
            local A4 = Limb2:Clone()
            Limb2.Parent = plr
            Limb2.Weld.Part1 = plr["Left Arm"]
            Limb2.Spread.Disabled = false
            wait(1.5)
            local A5 = Face:Clone()
            A5.Parent = plr
            A5.Weld.Part1 = plr["Head"]
            A5.Spread.Disabled = false
            wait(1.5)
        local children = plr:GetChildren()
        for i=1, #children do
            local instance = children[i]
            if (instance.ClassName == "Accessory") then
                if (instance.Handle:FindFirstChild("HairAttachment")) then
                    instance.Handle.BrickColor = BrickColor.new("Lily white")
                    instance.Handle.Mesh.TextureId = ""
            wait()
            for i=1, #children do
                local instance = children[i]
                if (instance.ClassName == "Accessory") then
                    if (not instance.Handle:FindFirstChild("HairAttachment")) then
                        instance:Destroy()
                    end
                end
            end
                    else

                    end
                end
            end
        end
    end

I did edit the script hence why its copying a copied item I tried to see if it would work like that.

1 answer

Log in to vote
1
Answered by
sleazel 1287 Moderation Voter
4 years ago

I am guessing the problem is here (lines 30 - 37):

            Limb.Parent = plr
            Limb.Weld.Part1 = plr["Right Arm"]
            Limb.Spread.Disabled = false
            wait(0.5)
            local A4 = Limb2:Clone()
            Limb2.Parent = plr
            Limb2.Weld.Part1 = plr["Left Arm"]
            Limb2.Spread.Disabled = false

You probably want to change Limb it to A3 and Limb2 to A4 respectively, as right now instead of parenting the cloned part, you are parenting the template. That is why script breaks after the second attempt, since some of the templates are gone from ServerStorage.

            A3.Parent = plr
            A3.Weld.Part1 = plr["Right Arm"]
            A3.Spread.Disabled = false
            wait(0.5)
            local A4 = Limb2:Clone()
            A4.Parent = plr
            A4.Weld.Part1 = plr["Left Arm"]
            A4.Spread.Disabled = false

Hope this helps!

0
Sadly it still failed Is there like any way to clone the parts multiple times because the script only clones it once for that single player on which has stepped on it first any other time it doesnt clone again to another person while that person is still alive. oshawat00 62 — 4y
0
It works in single player if the person dies then steps reover it however not if another person does, is there like a way to clone the items then make it so they are separate clones from what has already been cloned so it can be re-cloned and given to another person? oshawat00 62 — 4y
0
Ok nvm I'm just hella dumb ty. oshawat00 62 — 4y
Ad

Answer this question