Hi there! I made a script and I would like to know how to only change Y position with a Tween to avoid tweens conflicts. Can you help me please?
Hello. In the properties table of your tween, try doing Position.Y instead of Position.
local pos = Part.Position --assuming you aren't using CFrame
local offset = 5 --5 studs per tween
--tween goal-propertiesTable
local goal = {
Position = Vector3.new(pos.X, pos.Y+offset, pos.Z)
}
PS: The properties of constructors like CFrame
, Vector3
, Color3
etc. cannot be set directly(for example pos.Y += 5).
So, how to avoid tween conflicts between a tween which only modify position.X and a tween which only modify position.Y? Roblox should make this possible.
Do not store the starting position in a variable: Vector3.new(Part.Position.X, Part.Position.Y+offset, Part.Position.Z)
Is this work to avoid conflicts between two tweens which modify value of two different axis on the same part?
You shouldnt have two tweens on a single part. Instead try doing it with one tween.
This must also be applied to the tween which changes the X axis.
If I have a part which is spinning by using a Cylindrical Constraint and I want to change the CFrame of this part to modify his position, the part will stop spinning during a while and I don’t want it freeze each time it happen.
If I change the position of this part, parts attached to it by using welds will stay at the same place.
I’m not sure what you are trying to say, but changing the CFrame while trying to keep the effect of the cylindrical constraint wouldnt work with a tween because CFrame unlike position also holds the orientation of the part
That this the problem. I want to change the CFrame without change his orientation.
Then you should change the position and not the CFrame
Some parts are attached to the spinning part with weld constraints. If I use the position instead of CFrame, welded parts will stay at the same place.
What do you mean exactly . . ?
Here is how you would tween something’s CFrame without changing the orientation:
local partRotation = part.CFrame - part.Position
local yourTween = TweenService:Create(part, tweenInfo, {
CFrame = CFrame.new(x Position, y Position, z Position) * partRotation
})
So a practical example would be:
local part = workspace.PartToMove
local rotation = part.CFrame - part.Position
local tweenInfo = TweenInfo.new(3)
local movePartUp = TweenService:Create(part, tweenInfo, {
CFrame = CFrame.new(0, 20 , 0) * rotation
})
movePartUp:Play()
Hope this helps!
You can’t change one value of a Vector3 directly.