Cool Creations and Humiliations...


  • Mad Scientist ...Glum7 here,

    So I've apparently lost the ability of knowing how to rotate an object, I just noticed right after I finished a very nice wind sock (Git yur mind outta the gutter!! I mean those flag things that indicate wind at every airport ever)..

    You can check it out here:
    https://www.roblox.com/games/910859815/Airfield

    ..Anyway, Ive gotten myself this far, but I can't seem to rotate a model {before you say "you cant rotate a model.." iKnowYouCanOnlyRotateParts}
    I need this pole to rotate so that the wind sock can change direction, but on top of that, there are models within the model, I have no clue how to effectively get those children.

    Diagram:

    Game

      • -Workspace
        • -Model
          • -Model Within
          • Parts...

          • Parts...

        • -Parts

    rotation=true
    parts=script.parent.Model:GetChildren()
    for i=1,#parts do
    if rotation==true then
    parts[i].CFrame=CFrame.fromEulerAnglesXYZ(.1,0,0)*parts[i].CFrame
    else
    end

    I've also tried simpler layouts:

    v = script.Parent.Model:GetChildren()

    while true do
    v.CFrame = v.CFrame * CFrame.fromEulerAnglesXYZ(0.1,0,0)
    wait()

    end

    For this one I get Errors:
    21:18:38.264 - Workspace.WIND.Script:43: bad argument #1 to '?' (CFrame expected, got nil)
    21:18:38.265 - Stack Begin
    21:18:38.266 - Script 'Workspace.WIND.Script', Line 43
    21:18:38.267 - Stack End

    Seems to be a basic idea for a script, how would any of you do it?

    -Thanks

    G7


  • @Glum7 v is not an individual Part, v is an array containing individual Parts.
    You can call Model:GetPrimaryPartCFrame() and Model:SetPrimaryPartCFrame() instead to rotate all parts in the model according to the primary part.

    local wte = wait;
    local rot = CFrame.fromEulerAnglesXYZ;
    local children = script.Parent.Model:GetChildren();
    local mdl = script.Parent.Model;
    while wte() do
    mdl:SetPrimaryPartCFrame(
    mdl:GetPrimaryPartCFrame() * rot(0.1, 0, 0));
    end

    or if you want to rotate every individual part...

    local wte = wait;
    local rot = CFrame.fromEulerAnglesXYZ;
    local children = script.Parent.Model:GetChildren();
    while wte() do
    for i = 1, #children do
    if children[i]:IsA("BasePart") then
    children[i].CFrame = children[i].CFrame * rot(0.1, 0, 0);
    end
    end
    end

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.