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

Script not running when moved? [Solved]

Asked by
Scriptecx 124
8 years ago

So I have a script inside a model in Replicated Storage that welds the all of the parts together. The script works perfectly fine, but it's in Replicated Storage so it won't run, right? The wiki says that the script runs when it is moved into any service that it can run it, but it's not doing that. It's moving the parts but the weld script isn't welding the parts together. Help?!

--\\ Services
local JointsService = game:GetService('JointsService')

--\\ Variables
local Model = script.Parent
local WeldPart = Model.PrimaryPart

function Weld()
    local function WeldParts(Part, handle)
        Part.Anchored = false
        local weld = Instance.new("Weld")
        weld.Part0 = handle
        weld.Part1 = Part
        weld.C0 = handle.CFrame:inverse()
        weld.C1 = Part.CFrame:inverse()
        weld.Parent = JointsService
    end

    for _,obj in pairs (Model:GetChildren()) do
        if obj:IsA ("BasePart") or obj:IsA ("UnionOperation") then
            WeldParts (obj, WeldPart)
        end     
    end
end

Weld()
wait (1)
script:Destroy()
0
This is a server script? What service are you moving the script to? Is the script parented under a model? M39a9am3R 3210 — 8y
0
The script is in a model, Yes its a server script, and i'm moving it into a model inside Workspace. Scriptecx 124 — 8y
0
Never mind i fixed it, I did a repeat loop that waited until it the model was a descendant of Workspace. Scriptecx 124 — 8y

Answer this question