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

Make this cframe script move the whole model?

Asked by 6 years ago

Hello,

So I need some help here. How would I go about making it so that this script moves an entire model? Right now, it moves just a brick called 'Curtain'. If someone could please help that would be much appreciated.

Thanks, Anthony

local detector = game.Workspace.Part.ClickDetector;
local tween_service = game:GetService("TweenService")
local curtain = workspace:WaitForChild("Curtain");
local old_pos = curtain.CFrame;
local first = false;
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut);
local y = 50;
local cframe;

local PartB = part --Identify the part you want the curtain to move to.

function move_part()
    if first == false then
        first = true;
        cframe = PartB.CFrame --The cframe goal for the curtain.
    else
        first = false;
        cframe = old_pos;
    end
    local goal = {CFrame = cframe};
    local tween = tween_service:Create(curtain, info, goal);
    tween:Play();
end

detector.MouseClick:Connect(move_part);
0
I'm not sure if the tween service will work with full models. I'd probably just use PrimaryPartCFrame and do the tweening myself Perci1 4988 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You need to set a primary part which can be done under the properties of the model. That primary part will act as the focal point (Or the center) for the rotation. Here's an example of code you can use that moves the entire model -

Main:SetPrimaryPartCFrame(script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0.1,0))
-- Main is replaced by the model itself that you want moving. This would make the entire model rotate from PrimaryPart being the center. If rotation isn't what you meant, I'm sure you could figure out how to incorporate this into movement.

Not sure if this this helped at all, but hopefully it did.

Ad

Answer this question