I am creating a laser that sweeps a room. The laser is going into the camera. I want it to be able to rotate on a point the entire time.
code:
local tweenService = game:GetService("TweenService")
local laser = script.Parent
local endpoint = laser.Parent:FindFirstChild("laser end point")
local tweenInfo = TweenInfo.new(
3, -- length of tween in seconds
Enum.EasingStyle.Quad, -- Easing style
Enum.EasingDirection.InOut, -- Slows down at both finish areas
math.huge, -- repeats forever
true, -- Reverses
0 -- Delay
)
local Tween = tweenService:Create(laser, tweenInfo, {
CFrame = endpoint.CFrame
})
Tween:Play()
Video: (the other laser is the “endpoint” part)
That still doesn’t make it rotate on a point, I ended up using a rigid constraint to attach the laser to another part, unanchoring the laser, and only adding the script to the small part where it rotates from. (your script works fine). Finished result: