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

CFrame bugs out the whole model?

Asked by 5 years ago

Hi there!

Video for Reference

I am trying to make a train simulator. I know what I am doing in regards to making the train move along a track. I am also aware on how to control the doors to work, so when you press a button, a FOR loop changes the CFrame of multiple objects in specified directions.

However the doors do work (in their own isolated model), as you have seen in the video linked above. However as soon as I place a block beneath, model the part to the model so the tree looks like:

-Model
    - Part 
    - Train Model 
       - Train Door's parts

Then I weld that part to the door parts. And press the button to open the doors. The door and the part attached completely bugs out and flies away.

Please help me, I've been stuck on this for DAYS.

The OPEN DOOR script

locked = script.Parent.Parent.Locked
open = script.Parent.Parent.OpenValue
door = script.Parent.Parent.Door
left = door.left
right = door.right

function onClick()
    if locked.Value == true then
        return
    elseif locked.Value == false then
        if open.Value == false then
            open.Value = true
            for i=1, 21 do
                stuff = right:GetChildren() 
                stuffL = left:GetChildren()
                for i=1, #stuff do
                    if (stuff[i].className == "Part") or (stuff[i].className == "WedgePart") or (stuff[i].className == "UnionOperation") then
                        if (stuff[i].Name ~= "Button") then
                            stuff[i].CFrame = stuff[i].CFrame * CFrame.new(0.1,0,0)
                        end
                    end
                end
                for i=1, #stuffL do
                    if (stuffL[i].className == "Part") or (stuffL[i].className == "WedgePart") or (stuffL[i].className == "UnionOperation") then
                        if (stuffL[i].Name ~= "Button") then
                            stuffL[i].CFrame = stuffL[i].CFrame * CFrame.new(-0.1,0,0)
                        end
                    end
                end
                wait(0)
            end
        elseif open.Value == true then
            return
        end
    end
end


script.Parent.Click.MouseClick:Connect(onClick)
0
I have also tried using a weld script to weld the object to the parts I want. But same result. It only seems to work when it ISN'T welded to the part. SomeRandomScorpion 1 — 5y
0
Is this your script? User#19524 175 — 5y
0
Yes SomeRandomScorpion 1 — 5y
0
It seems to only work with the weld when the model is anchored, when no parts, other than the parts I am Cframing, move. It works fine without the weld (Anchored and Unanchored). SomeRandomScorpion 1 — 5y
View all comments (2 more)
0
However there's not much of a workaround that I know of because the parts need to be welded and unanchored, as a train cannot move when anchored, and falls to bits when it's not welded. SomeRandomScorpion 1 — 5y
0
I've tried various weld scripts, and as seen in the video, manually welding the part to the doors. SomeRandomScorpion 1 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Discord : CoreyHimself#7545

Ad

Answer this question