Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to make orb follow to the side of player?

I'm trying to get an orb to always stay on the right side of the player.

i know have to do something with angles but i keep getting errors.

what i've got just makes the orb follow behind the players head

whenever i try to use angles i get incompatible error.

i guess angles is incompatible with position?

this script is inside the orb

and i'm using a BodyPosition to move it around

the orb is inside the players head

local Part = script.Parent local BodyPosition = script.Parent.BodyPosition local Character = script.Parent.Parent

while Part and Part.Parent and wait(.1) do BodyPosition.position = Character.Head.Position + -Character.Head.CFrame.lookVector*2 end

2 answers

✓ Accepted answer

You actually have to rotate the Head's CFrame before taking it's lookVector, since Vector3s don't support any kind of "rotation":

local Part = script.Parent
local BodyPosition = script.Parent.BodyPosition
local Character = script.Parent.Parent

while Part and Character and wait(.1) do
	BodyPosition.position = Character.Head.Position + 
		(Character.Head.CFrame*CFrame.Angles(0, math.rad(90), 0)).lookVector*2
	--If 90 doesn't work, try -90.
end

1 comment

0

worked perfect ty so much! yes -90 for right side. I was so close a few times but just couldnt get the formula right. much appreciated

If I were you, I'd just add a vectorToWorldSpace value to the bodyposition.

--Assuming the script is within the orb within the head
while wait(0.1) do
BodyPosition.position = script.Parent.Parent.Position + script.Parent.CFrame:vector.ToWorldSpace(Vector3.new(0,10,0))
end

The Vector3 value inside of the vectorToWorldSpace is the offset at which the orb follows your head

This discussion is preserved as it was. New answers, comments, and votes are closed.