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

can somone help me with this rotation/position problem?(changed,still need help)

Asked by 8 years ago

ok, I have changed this like 5 times now.

what happens is that the model rotates all in one movement(but not to were I told t to go) and the model moves up slowly like I told it to and the print statements work.

why wont the rotate work?

ok... the start (rotation) position is 90 and I need it to rotate up slowly until it hits -65

a the same time the model needs to move up and right slowly to keep it in the same spot.

with this code it moves up and over but don't rotate right. (pleas help!)

local ArmOne = script.Parent.Parent.ArmRotatorTwo.ArmOne
local ArmTwo = script.Parent.Parent.ArmRotatorTwo.ArmTwo
local Rotater = script.Parent.Parent.BraceRotater
local Four = script.Parent.Parent.ArmRotatorTwo.PartFour
local One = script.Parent.Parent.ArmRotatorTwo.PartOne
local Three = script.Parent.Parent.ArmRotatorTwo.PartThree
local Two = script.Parent.Parent.ArmRotatorTwo.PartTwo
local Brace = script.Parent.Parent.ArmRotatorTwo.Brace
local Left = script.Parent.Parent.ArmRotatorTwo.LeftArm
local Right = script.Parent.Parent.ArmRotatorTwo.RightArm
local Model = ArmTwo.Parent
local Prime = Model.PrimaryPart
local ArmRotation = ArmTwo.Rotation.Z
local NumberOne = 0
local NumberTwo = 0


    Rotater.CanCollide = false
    ArmOne.CanCollide = false
    ArmTwo.CanCollide = false
    Four.CanCollide = false
    One.CanCollide = false
    Three.CanCollide = false
    Two.CanCollide = false
    Brace.CanCollide = false
    Left.CanCollide = false
    Right.CanCollide = false


function Rotate()
    wait(.5)    
    print ("Start") 
    while (ArmRotation > -65) do    

        Model:SetPrimaryPartCFrame(CFrame.new(Prime.CFrame.X - .05, Prime.CFrame.Y + .05, Prime.CFrame.Z))
        wait(.2)
print ("Done Step One")
        CFrame.Angles(Prime.Rotation.X, Prime.Rotation.Y, Prime.Rotation.Z - 0.05)


print ("Done Step Two")     
        NumberOne = NumberOne + 1       
        print(NumberOne)        
        wait(.2)
    end

        --while (Model > -65) do    
        --Model:SetPrimaryPartCFrame(CFrame + Vector3.new (Prime.CFrame.X - .05, Prime.CFrame.Y + .05, Prime.CFrame.Z)) 
        --wait(.2)
        --CFrame.Angles(Prime.Rotation.X, Prime.Rotation.Y - 0.05, Prime.Rotation.Z)

        --NumberOne = NumberOne + 1     
        --print(NumberOne)      
        --wait(.2)

    end

    script.Parent.ClickDetector.MouseClick:connect(Rotate)  

    wait(.1)

    Rotater.CanCollide = true
    ArmOne.CanCollide = true
    ArmTwo.CanCollide = true
    Four.CanCollide = true
    One.CanCollide = true
    Three.CanCollide = true
    Two.CanCollide = true
    Brace.CanCollide = true
    Left.CanCollide = true
    Right.CanCollide = true


I have tried many different things, and I cant find any video's on this can someone help me.

0
P.S. if i use * the frame just jumps around twisting snipers0076 5 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Move the model as a whole using SetPrimaryPartCFrame, All you need is to set the model's PrimaryPart to the part in the center.


SetPrimaryPartCFrame(CFrameValue CFrame)

I think this way is better because you can move the whole model, and with cframe you can set position and rotation

Model:SetPrimaryPartCFrame(CFrame.new(0,10,0))
Model:SetPrimaryPartCFrame(CFrame.new(0,0,5) * CFrame.Angles(0,math.pi,0))


Final Product

local ArmOne = script.Parent.Parent.ArmRotatorTwo.PartOne
local ArmTwo = script.Parent.Parent.ArmRotatorTwo.PartTwo
local Rotater = script.Parent.Parent.BraceRotater
local Four = script.Parent.Parent.ArmRotatorTwo.PartFour
local One = script.Parent.Parent.ArmRotatorTwo.PartOne
local Three = script.Parent.Parent.ArmRotatorTwo.PartThree
local Two = script.Parent.Parent.ArmRotatorTwo.PartTwo
local Brace = script.Parent.Parent.ArmRotatorTwo.Brace
local Left = script.Parent.Parent.ArmRotatorTwo.LeftArm
local Right = script.Parent.Parent.ArmRotatorTwo.RightArm
local Model = Rotater.Parent
local Prime = Model.PrimaryPart


function Rotate()
    wait(.5)

    Rotater.CanCollide = false
    ArmOne.CanCollide = false
    ArmTwo.CanCollide = false
    Four.CanCollide = false
    One.CanCollide = false
    Three.CanCollide = false
    Two.CanCollide = false
    Brace.CanCollide = false
    Left.CanCollide = false
    Right.CanCollide = false

    while (Two.Rotation.Z >  -45) do
    Model:SetPrimaryPartCFrame(CFrame.new(Prime.CFrame.X-.004, Prime.Position.Y+.015, Prime.Position.Z)*CFrame.Angles(Prime.Rotation.Z,Prime.Rotation.Y, Prime.Rotation.Z - 0.5))
        Two.CFrame = Two.CFrame*CFrame.Angles(One.Rotation.X, One.Rotation.Y + .406, One.Rotation.Z)
        end

    while (Two.Rotation.Z > -65) do
        Model:SetPrimaryPartCFrame(CFrame.new(Prime.CFrame.X+.004, Prime.Position.Y-.015, Prime.Position.Z)*CFrame.Angles(Prime.Rotation.Z,Prime.Rotation.Y, Prime.Rotation.Z - 0.5))
        wait(.1)
        end
    end  


    Rotater.CanCollide = true
    ArmOne.CanCollide = true
    ArmTwo.CanCollide = true
    Four.CanCollide = true
    One.CanCollide = true
    Three.CanCollide = true
    Two.CanCollide = true
    Brace.CanCollide = true
    Left.CanCollide = true
    Right.CanCollide = true

script.Parent.ClickDetector.MouseClick:connect(Rotate)

Edit the script as needed.



Hope it helps!

Ad

Answer this question