Hello! I know this isnt a request site and I am not trying to request anything. I only want to know: How do I make a part (my shields) move around a player that's touching a part? I have tried googling, doing it myself etc but I cant find anything on how to make parts spin around the player, and I also don't know how I would make the touched function send the player variable to the server so it would make only the touching player have the shields. If you guys think this is a request please comment notifying me and ill remove it imideatly! Sorry if this question is badly formulated or asked, I don't ask things like this very often
EDIT: Purpose is spawn protection, when the player touches a non collide brick that's invisible a touched event will be fired and make the player have the shields spinning around it until it stops being in the spawn (brick)
This is where we use maths.
If you aren't familiar with parametric equations then this might fly over your head.
We know that x = rcos?
and y = rsin?
. Which is coincidentally the equation for a circle. If we use a loop to set a part's position to this, relative to the player's torso, or head we will achieve circular orbit.
I'm not going to go step-by-step so I hope you can reverse-engineer this to fit your own needs.
local function moveCircle(theta, radius) local Head = Player.Character:WaitForChild("Head") local positionX = radius * math.cos(theta) local positionZ = radius * math.sin(theta) script.Parent.CFrame = CFrame.new(Head.Position.X + positionX, Head.Position.Y, Head.Position.Z + positionZ) end while wait() do local theta = tick() moveCircle(theta, 10) end
If you know the parametric equations for a shape, you can make that orbit.