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
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.