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

So I cant find out how to move the cframe of this object using tweening?

Asked by 4 years ago

So I wrote this code to tween a certain object to a certain position

local Part = script.Parent
    local Length = 3.5

    local TweenService = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(

    Length, 
    Enum.EasingStyle.Linear, 
    Enum.EasingDirection.In,
    0, 
    false, 
    0 
)



local goal = {} 
goal.Color = Color3.fromRGB(205, 205, 205)
goal.CFrame = workspace.MoveHere2.CFrame
goal.Transparency = 0
goal.Reflectance = 0

local tween = TweenService:Create(Part, tweenInfo, goal)
tween:Play()

so the "MoveHere2" Part is a part I made so I didn't have to specify a CFrame but it glitches out the original part when I make it move here, the reason why, I think, is that it's trying to move up and sideways at the same time, so it does not smooth and it just jumps around over the place.

For example: If I was trying to make a vent door fall open i'd need to change the orientation + the height and the z-axis position, but then when it runs the code it flops around everywhere until it gets to the position but thats not the goal, the goal is to make it smooth while going to that position

1 answer

Log in to vote
2
Answered by 4 years ago

Hello! You have to use put the goals in a table. I saw that you did not add the goals to the table properly. Instead, try this:

local Part = script.Parent
    local Length = 3.5

    local TweenService = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(

    Length, 
    Enum.EasingStyle.Linear, 
    Enum.EasingDirection.In,
    0, 
    false, 
    0 
)



local goals = { 
    Color = Color3.fromRGB(205, 205, 205),
    CFrame = workspace.MoveHere2.CFrame,
    Transparency = 0,
    Reflectance = 0
}

local tween = TweenService:Create(Part, tweenInfo, goals)
tween:Play()

This will make all of the goals go in a table.

0
oh wow lol that sure did fix it didnt know it would be that simple of a fix, anyways thanks! NvidiaGeForce2080Ti -5 — 4y
Ad

Answer this question