Hello, I’m trying to make a sphere part that sort of acts like a curve when it’s going to it’s target, using BodyPosition. It’s working well so far, except for the fact that the bodypostion’s poisition is always 0,0,0 even though I’m setting it to something else:
local backpart = workspace.Part
local target;
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
target = character:FindFirstChild("HumanoidRootPart")
end)
end)
repeat wait() until target
while wait() do
-- print('x') -- prints
local mag_from_backpart = (backpart.Position - script.Parent.ball.Position).Magnitude
local mag_from_target = (target.Position - script.Parent.ball.Position).Magnitude
if mag_from_backpart <= 5 then
script.Parent.BodyPosition.Position = Vector3.new(target.CFrame:VectorToObjectSpace(script.Parent.ball.Position))
elseif mag_from_target <= 5 then
script.Parent.BodyPosition.Position = Vector3.new(backpart.CFrame:VectorToObjectSpace(script.Parent.ball.Position))
else
script.Parent.BodyPosition.Position = Vector3.new(target.CFrame:VectorToObjectSpace(script.Parent.ball.Position))
end
end
It would also be helpful if someone could direct me to another resource for accomplishing this, because this method doesn’t seem very useful and it feels hard to script. Thank you