Positioning parts like a star around the player?

Hey there! so, I wanted to create something recently and I have no idea on how I would create it (I also started becoming curious on how this would be possible)
see I want to create a star around the player so like this:
image
(the yellow parts are the parts of the Star and the green part is the player)

How would I create this? Thanks!!

Do you mean something along the lines of star.Position = character.HumanoidRootPart.Position + Vector3.new(5, 0, 5)?

1 Like

Yeah but how would i make every part position so it goes like a star (like in the picture)

Spinning continuously or not spinning at all?

1 Like

Not spinning at all chaaaars

Alright, I’ve quickly made this code that will keep the star by the player smoothly:

game.Players.LocalPlayer.CharacterAdded:Wait()

while wait() do
	game.TweenService:Create(workspace.Star.PositionCFrame, TweenInfo.new(0.5), {Value = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame.Position + Vector3.new(5, 0, 0))}):Play()
	workspace.Star:SetPrimaryPartCFrame(workspace.Star.PositionCFrame.Value)
end

To move the star position, you just have to change the + Vector3.new(5, 0, 5) to something else, for example: (5, 0, 0)

This is what it looks like:


(Transparent part is MainPart and yellow part is Star)
2

1 Like

here is a demo project that might help
Positioning parts like a star.rbxl (34.7 KB)

and this is what it looks like

and this is the script inside the demo project

local runService = game:GetService("RunService")

local character = script.Parent
local rootPart = character.HumanoidRootPart
local distance = 10
local amount = 5
local parts = {}

for i = 1, amount do
	parts[i] = Instance.new("Part")
	parts[i].Anchored = true
	parts[i].Size = Vector3.new(2, 2, 2)
	parts[i].Parent = workspace
end

runService.Heartbeat:Connect(function(deltaTime)
	for i = 1, amount do
		local angle = i / amount * math.pi * 2
		local offset = Vector3.new(math.sin(angle), 0, math.cos(angle)) * distance
		parts[i].Position = rootPart.Position + offset
	end
end)

and this video might help you understand the angle = i / amount * math.pi * 2 part

i will hopefully have a video in the future talking about sin and cos

7 Likes