Alternatives to Tween that have the ability to collide?

  1. What do you want to achieve? Keep it simple and clear!
    A sphere that follows players on all axes and collides with other parts

  2. What is the issue? Include screenshots / videos if possible!
    Tweening (which is currently the best solution I have) doesn’t detect collisions, so the sphere goes through parts

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried pretty much every alternative to tweening and some DO work (such as AlignPosition), but they chase by rolling and don’t ‘fly’ towards the player

Code that moves the sphere:

local function followPlayer(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

	if character.Humanoid.Health > 0 then
		local distance = (part.Position - humanoidRootPart.Position).Magnitude
		if distance > 0 then -- Change this value to adjust how close the part gets to the player
			local tweenInfo = TweenInfo.new(
				0.5, -- Time in seconds for the tween
				Enum.EasingStyle.Linear, -- Easing style of the tween
				Enum.EasingDirection.Out, -- Easing direction of the tween
				0, -- Number of times to repeat
				false, -- Should the tween repeat?
				0 -- Delay time
			)
			local goal = {}
			goal.CFrame = CFrame.new(part.Position, humanoidRootPart.Position) * CFrame.new(0, 0, -5) -- Change the -5 to adjust the speed of the part
			local tween = TweenService:Create(part, tweenInfo, goal)
			tween:Play()
			
			--[[ code for AlignPosition
			local attachment = Instance.new("Attachment")
			attachment.Parent = humanoidRootPart
			part.AlignPosition.Attachment1 = attachment
			]]
		end
	end
end

Is this an ai generated script?

I think su can use something called “normal” i think that it detects if it hits a part

i don’t think so? i stole a good portion of it and edited it to better suit my needs

i don’t want it to just detect whenever it hits a part, i want it to interact with other parts and stop when blocked (for example)

use physics, and constraints, remember that roblox physic engine can get messy and your ball will magically launch into the void sometimes, but still it’s good

…and what am i specifically supposed to use?

Use RayCast function in order to get along with this task. Instead of Tweening, I suggest you to use the :MoveTo() function which will make the Sphere follow player irrespective of any object in middle of displacement or waypoint or way.

doesn’t :MoveTo() only make characters with humanoids walk? that’s not what i’m searching for

I found a solution by myself: I moved the sphere backwards when it touches an object. yeah, it was that simple. here’s the code i used:

if character.Humanoid.Health > 0 then
		local distance = (part.Position - humanoidRootPart.Position).Magnitude
		if distance > 0 then -- Change this value to adjust how close the part gets to the player
			local tweenInfo = TweenInfo.new(
				0.5, -- Time in seconds for the tween
				Enum.EasingStyle.Linear, -- Easing style of the tween
				Enum.EasingDirection.Out, -- Easing direction of the tween
				0, -- Number of times to repeat
				false, -- Should the tween repeat?
				0 -- Delay time
			)
			local goal = {}
			if e == 0 then
				goal.CFrame = CFrame.new(part.Position, humanoidRootPart.Position) * CFrame.new(0, 0, -5)
			else
				local newPosition = part.Position - 10 * part.CFrame.LookVector
				goal.CFrame = CFrame.new(newPosition) * CFrame.new(0, 0, -5)
			end

			local tween = TweenService:Create(part, tweenInfo, goal)
			tween:Play()
		end
	end