Tweening a part that stays on a point at all times (thanks for helping!)

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)

thanks for helping!

You don’t even need “laser end point” then.

Code:

local tweenService = game:GetService("TweenService")
local laser = script.Parent

local angle = 90

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 = laser.CFrame * CFrame.Angles(math.rad(angle), 0, 0)
})

Tween:Play()

Set angle to a value that works for you.

1 Like

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:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.