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

Having trouble getting UpVector while tweening to make a rocket, is there any solution to this?

Asked by 4 years ago
Edited 4 years ago

Hello,

Im currently trying to figure out how to make a spaceship with the roblox TweenService and its all going good so far until i started 'tweening', there is nothing 'wrong' with my code. I want to get the UpVector of a part and tween it from there but the parts instead of going straight up they go a little to the side.

local tweenService = game:GetService("TweenService")

-- These three parts are wielded together with stage 2 as 'center' part
local Stage1 = script.Parent:WaitForChild("Stage1")
local Stage2 = script.Parent:WaitForChild("Stage2")
local finalStage = script.Parent:WaitForChild("FinalStage") --

local studs = script.Parent:WaitForChild("Studs").Value -- how high up it should go (set to 50)

local stage1Fire = Stage1:WaitForChild("Fire"):WaitForChild("ParticleEmitter") -- ignore this

local luanchButton = script.Parent:WaitForChild("Luanch"):WaitForChild("Detector")

local tweenInfo = TweenInfo.new(
    script.Parent.MaxVel.Value / 60, -- just so i could set studs per minute
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.In,
    0,
    false,
    0
)

local function luanch()
    local properties = {
        CFrame = CFrame.new(Stage2.CFrame.UpVector * Vector3.new(1, studs, 1)) -- I think its somwhere here the problem is.
    }

    local tween = tweenService:Create(Stage2, tweenInfo, properties)

    tween:Play()
end

luanchButton.Triggered:Connect(luanch) -- Im using a ProximityPrompt 

I have created a video here if i have been bad at explaning

Thanks for taking your time!

1 answer

Log in to vote
1
Answered by
ew_001 58
4 years ago

Yes the problem is indeed on line 25.

Instead of this.

CFrame = CFrame.new(Stage2.CFrame.UpVector * Vector3.new(1, studs, 1))

It should be this.

CFrame = Stage2.CFrame + Stage2.CFrame.UpVector * studs

This is because UpVector returns a Vector3 value that is 1 stud above the Intance, so then you can multiply it with an number to make it higher. Then you add the CFrame of the Instance so it combines the rotation and position together.

I hope you understand and that this helps!

0
Thanks, it really helped! Love_LoL01 7 — 4y
0
You should really accept the answer then kingblaze_1000 359 — 4y
0
i tried but i didnt know how before, now i know Love_LoL01 7 — 4y
Ad

Answer this question