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

How do i make maths in position of vector3.new?

Asked by 3 years ago

I want to make animated part that starts while loop and makes part move in X axis, and stops the part when its in position i want it to be, something like this

(code below is an example)

local blah = game.workspace.blah
blah.Touched:Connect(function()
while true do
blah.position = vector3.new(0,0,0) + 1 -- in x axis only
if blah.position == vector3.new(100,0,0) then
stop loop and dont let the part move
end

Sorry for my english

0
welp, i think im not going to get anserwed Dawnymurzyn 7 — 3y
0
Try tweenservice or maybe use CFrame :) could work. xsodar 19 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hi, dunno if you'll see this but it seems you want a tween. If you don't know what a tween is, then i recommend to look here. Now, lets work coding on it.

-- Services --
local twService = game:GetService("TweenService")

-- Variables --
local blah = script.Parent

local info = TweenInfo.new(
    10, -- How long it should play.
    Enum.EasingStyle.Linear, -- How it should move.
    Enum.EasingDirection.In, -- Direction of how to tween.
    0, -- Re-Playing it, 0 means no re-playing.
    false, -- Should it do back to it's original position? For this no.
    0 -- How long will the script wait until executing the info.
)

local goal = {
    Position = Vector3.new(100, 0, 0)
}

local tween = twService.new(blah, info, goal) -- 1. parameter is the target, 2. parameter is the info of tween, 3. parameter is the goal of tween

-- Function --
function playingTween()
    tween:Play()
end

-- Event --
blah.Touched:Connect(playingTween)

Hopefully I could help you. If it doesn't work like you wanted, you can tell me. Possibly I can help you, g'day.

Ad

Answer this question