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

Why are objects fixed in place?

Asked by 6 years ago
Edited 6 years ago

Hey!

So I'm trying to weld an object to another, which is easy enough. The script has always worked, and functions with other objects, however this object in studio will not position properly. It welds fine and moves with the character however it is welded relative to where it is in 3d space in replicated storage, not where I've positioned it. Messing with the CFrame and trying to move it changes nothing, it still only appears and remains welded relative to its position in space. There are no motors or others welds inside the object, it is uncollidable and unanchored. Has anyone heard of this happening before? It isn't too relevant but in case it helps I'm including the weld script below.

local Accessory = game.ReplicatedStorage.GameObject

local function onEventFired(player)
    local g = Accessory:Clone()
    g.Parent = player.Character
    local C = g:GetChildren()
    for i=1, #C do
        if C[i]:IsA("BasePart") then
            local W = Instance.new("Weld")
            W.Part0 = g.Middle
            W.Part1 = C[i]
            W.C0 = g.Middle.CFrame:inverse()*C[i].CFrame
            W.Parent = g.Middle
        end
        local Y = Instance.new("Weld")
        Y.Part0 = player.Character.Head
        Y.Part1 = g.Middle
        Y.C0 = CFrame.new(0, 0, 0)
        Y.Parent = Y.Part0
    end

    local h = g:GetChildren()
    for i = 1, # h do
        h[i].Anchored = false
        h[i].CanCollide = false
    end
end

p.s. the 'middle' part welds perfectly, just not any of the other baseparts in the Accessory model. This script works absolutely fine on other objects and always has. I cannot find any record anywhere of objects just refusing to move in game even when their CFrame is messed with

Answer this question