Tween alternative

i want to move something and detect collisions but that cant happen with tween so what do i use?
i was doing this before that detected collisions with characters but not with any other part

				game:GetService("TweenService"):Create(new, TweenInfo.new(Time), {Position = mouseLoc.p}):Play()
				new.Touched:Connect(function(part)
					task.spawn(function()
						spell.OnTouch(part, player, mouseTarget)
					end)
					if part.Parent.Name ~= player.Name then
						new:Destroy()
					end
				end)

You can use CFrame:Lerp() to move parts just like Tweening, but in-between, you can detect collisions.

for i = 0, 1, 0.01 do -- To increase speed you can change the 0.01 to a higher number
    new.CFrame = new.CFrame:Lerp(mouseLoc, i)
    task.wait()
end

Assuming mouseLoc is a CFrame

2 Likes

(script not tested however should work)
I know the last replier here is probably right but I’d use

local part = workspace.Part -- your part location here

local targetXlocation = 10 -- let's say you want your part to go to x:10 y:0 z:0
local timeLength = 1 -- enter in the time you want the transition to take
local smoothness = 1 -- enter in a number from 1 to 10

local smoothness = 0.01 / smoothness
for i = 0, 1, smoothness do
    part.Position = Vector3.new(i * targetXlocation, 0, 0) -- of course change the 'y' and 'z' values to the position of the part 
    wait(0.01 * timeLength * smoothness)
end

if you use
https://developer.roblox.com/en-us/api-reference/class/AlignPosition
then collisions will be detected

make sure to set anchored to false

you might also want to set cancollide to false if you dont want anything blocking it while it moves

1 Like

I mean i would just use bodyposition

Unless Roblox management did another oopsie I wouldn’t because
image

Just because its deprecated doesn’t mean it isn’t a good choice, the only reason it is deprecated is because they are making an improved version of all bodymovers its fine how it is right now for use since the new versions are actually less flexible and also require attachments

According to Wikipedia:

In several fields, especially computing, deprecation is the discouragement of use of some terminology, feature, design, or practice, typically because it has been superseded or is no longer considered efficient or safe, without completely removing it or prohibiting its use.

And so, when Roblox deprecate something, they don’t want you to use it anymore unless you literally cannot make the change due to hardcoded or spaghetti code in older games
Hence why I said “unless Roblox made another oopsie” since they have a pretty good track record of deprecating things before the newer alternatives have been perfected

So, either Roblox management screwed up again badly (with zero corrections within the past month) or there’s a good reason why BodyMovers have been deprecated for a while now with no reversions?

Roblox never messed up you can read more about the new body movers here well there not new anymore they have been out for years now