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:
(the yellow parts are the parts of the Star and the green part is the player)
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)
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