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

Clone & weld code working when object in workspace but not when in replicatedstorage?

Asked by 5 years ago

So I just got a code that gets a set of objects & welds a clone of it to the player but now when I try to put the objects in replicatedstorage it doesn't work

Here is the code:

function WeldEnable (x, y, z)
    if Prt1:FindFirstChild("weld") == nil then
        Prt1.CFrame = Prt0.CFrame * CFrame.new(x, y, z)
        weld = Instance.new("Weld")
        weld.Part0 = Prt0
        weld.C0 = Prt0.CFrame:Inverse()
        weld.Part1 = Prt1
        weld.C1 = Prt1.CFrame:Inverse()
        weld.Parent = Prt1
        weld.Parent.Anchored = false
        weld.Parent.CanCollide = false
    end
end

function FrameOn()
    newSuit = Suit:Clone()
    newSuit.Parent = workspace
    Prt0 = Target:FindFirstChild("Head")
    Prt1 = newSuit:FindFirstChild("Head")
    WeldEnable(0, 0, 0)
    Prt0 = Target:FindFirstChild("LeftLowerArm")
    Prt1 = newSuit:FindFirstChild("LowerLeftArm")
    WeldEnable(0, -0.276, 0)
    Prt0 = Target:FindFirstChild("LeftLowerLeg") -- LowerLeg -0.0965
    Prt1 = newSuit:FindFirstChild("LowerLeftLeg")
    WeldEnable(0, -0.2965, 0)
    Prt0 = Target:FindFirstChild("RightLowerArm")
    Prt1 = newSuit:FindFirstChild("LowerRightArm")
    WeldEnable(0, -0.276, 0)
    Prt0 = Target:FindFirstChild("RightLowerLeg") -- LowerLeg
    Prt1 = newSuit:FindFirstChild("LowerRightLeg")
    WeldEnable(0, -0.2965, 0)
    Prt0 = Target:FindFirstChild("LeftUpperArm")
    Prt1 = newSuit:FindFirstChild("UpperLeftArm")
    WeldEnable(0, 0.1345, 0)
    Prt0 = Target:FindFirstChild("LeftUpperLeg")
    Prt1 = newSuit:FindFirstChild("UpperLeftLeg")
    WeldEnable(0, -0.0965, 0)
    Prt0 = Target:FindFirstChild("RightUpperArm")
    Prt1 = newSuit:FindFirstChild("UpperRightArm")
    WeldEnable(0, 0.1345, 0)
    Prt0 = Target:FindFirstChild("RightUpperLeg")
    Prt1 = newSuit:FindFirstChild("UpperRightLeg")
    WeldEnable(0, -0.0965, 0)
    Prt0 = Target:FindFirstChild("UpperTorso")
    Prt1 = newSuit:FindFirstChild("Torso")
    WeldEnable(0, -0.2, 0)
end

Suit = game.Workspace.SuitFrame
Target = workspace:WaitForChild("CoolOlivie057")
FrameOn()

Btw I made sure that when I moved 'SuitFrame' into replicated storage I changed Suit to:

Suit = game.ReplicatedStorage.SuitFrame
0
Objects in ReplicatedStorage don't actually show up in-game, the part has to be parented to Workspace to show up CPF2 406 — 5y
0
K CoolOlivie057 45 — 5y
0
but it already sets the parent to workspace in the script CoolOlivie057 45 — 5y
0
Nvm turns out that since the script was a child of the part, when I put the part in replicated storage the script moved with it so it didn't work CoolOlivie057 45 — 5y
View all comments (2 more)
0
So you fixed it? Goulstem 8144 — 5y
0
yes sorry for the late reply, yes I fixed it. CoolOlivie057 45 — 5y

Answer this question