Tweening Part to stop at wall with Raycasting?

Hello, I’m looking to make a part stop at a wall when tweening, but I am not very experienced in
Raycasting to do so, could someone give me an example?

So far how I’m tweening is tweening a gray part to a red part’s CFrame & Size.
screenshot2

screenshot1

Here is my tweening code that I want to add the raycasting to:

local TS = game:GetService("TweenService")

local TSInfo = TweenInfo.new(
	
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	0,
	false
)

local TW = TS:Create(script.Parent.Part, TSInfo, {CFrame = script.Parent.TweenSize.CFrame})
local TW2 = TS:Create(script.Parent.Part, TSInfo, {Size = script.Parent.TweenSize.Size})

wait(2)

TW:Play()
TW2:Play()

How would I mix raycasting and tweening together? I want the raycast to come from the gray part
and then tween the red part’s size to how far the raycast goes.

1 Like

If you want something like this:


I hope this model will give you an idea
Raycast.rbxm (4,1 KB)

If this is not what you are looking for, please be more specific so I can help you. :smile:

1 Like