How its possible so the Model moves in the X Axis from its own position?
3 Likes
You can use Model:MoveTo(Vector3 pos) to move the model, and use Model:GetBoundingBox() to get the CFrame and position of the model.
Example:
local model = workspace.Model --Path to the model
local pos = model:GetBoundingBox().Position --Middle position of the box.
local XPos = 0 -- Your Vector3 X Position
model:MoveTo(Vector3.new(XPos, pos.Y, pos.Z)
Model:MoveTo()
Model:GetBoundingBox()
If you want it to move the X from it’s current Position, you can just set XPos to pos.X and then make changes to XPos.
I am not sure whether .p or .Position on a CFrame will work, try both.
Take the models position, and add or substract from the first number (the x axis)
Use tween service and CFrames
for example:
local TweenService = game:GetService("TweenService")
local part = game.Workspace.Part
local Info = TweenInfo.new(
2, -- How long it takes to finish (Seconds)
Enum.EasingStyle.Sine, -- Moving Style
Enum.EasingDirection.Out, -- I think this only matters in GUIs
2, -- How many times it should repeat 0 if you want it to move and back once
true, -- Should It Go back?
0 -- Delay(Seconds)
)
local goal = {
CFrame = part.CFrame + Vector3.new(10,0,0) -- (X,Y,Z) you need to change the x depending on how much you want it to move
}
local Move = TweenService:Create(part, Info, goal)
wait(3)
Move:Play()