How do I use tween service to move floor lasers?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Trying to make floor lasers use tween service

  2. What is the issue? The floor lasers don’t move smoothly.

  3. What solutions have you tried so far?

– Code doesn’t use tween service…
local CamreaLight = script.Parent
local Moved = 0

function MoveLeft()
for i = 30,0,-1 do
Moved = Moved - 1
CamreaLight.Position = CamreaLight.Position + Vector3.new(0,0,-1)
wait(0.01)
end
end

function MoveRight()
for i = 0,30,1 do
Moved = Moved + 1
CamreaLight.Position = CamreaLight.Position + Vector3.new(0,0,1)
wait(0.01)
end
end

while wait(0.01) do
MoveRight()

repeat wait() until Moved >= 30

MoveLeft()

repeat wait() until Moved <= 0

end

How do I change this code to use tween service instead?

TS is pretty easy actually, and much better than any other forms of interpolation:

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
local tweenTab = {Position = Vector3.new(0, 5, 0)} --the position to move to
local tween = ts:Create(laser, ti, tweenTab)

tween:Play()

--make your tween repeat forever (set to negative number)
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingStyle.Out, -1) 

--make your tween reverse (animate backwards after finished)
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingStyle.Out, -1, true) --add true

--how much time between each repeat?
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingStyle.Out, -1, true, 0.5) --0.5 secs

That’s a basic overview. You can change it however you’d like.

BTW, here’s @Alvin_Blox’s TweenService tutorial:

Ok that is cool I will try to make it work.