You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want my blades to form a semi-circle starting from either side of my head, curving on top of my head, ending on the other side
-
What is the issue? Include screenshots / videos if possible!
the issue is that the first and the tenth blade seem to always point towards the negative x-axis on the world’s orientation
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried my best understanding this → Make revolving parts around a character - #4 by prepsure, but to no avail I couldn’t make the first and tenth blade behave like the other 8 in between, even with ai they couldn’t achieve what I want to happen
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I tried forming it in a circle, but even as a circle it doesn’t look quite right, I’m not exactly sure where the problem lies in this case. This ability/spell is highly inspired by the Wheel of Time’s Siuan Sanche’s most used moved, a weave of hardened air that turn into blades
This is the full code
local RS = game:GetService("ReplicatedStorage")
local BladeFolder = RS:WaitForChild("Blade")
local BladeOn = BladeFolder:WaitForChild("BladeOn")
local BladeVelocity = BladeFolder:WaitForChild("BladeVelocity")
local BladeRS = BladeFolder:WaitForChild("Blade")
BladeOn.OnServerEvent:Connect(function(Player, playerLevel)
local Character = Player.Character
local Head = Character:WaitForChild("Head") -- Get the head of the character
local numberOfBlades = 10
local radius = 5 -- Distance from the head (adjust as needed)
print("Spawning blades...") -- Debug message for starting the loop
for i = 1, numberOfBlades do
print("Creating blade " .. i) -- Debug message for each blade
local bladeClone = BladeRS:Clone() -- Use BladeRS to clone the blade
-- Set the blade name to include the index
bladeClone.Name = "Blade_" .. i
print("Blade " .. i .. " name set to:", bladeClone.Name)
bladeClone.Parent = workspace -- Place blade in the world
print("Blade " .. i .. " parented to workspace")
-- Calculate the angle for each blade to create a curve
local angle = math.pi * (i - 1) / (numberOfBlades - 1) -- Divide the angle evenly from 0 to pi
print("Blade " .. i .. " angle:", math.deg(angle)) -- Print angle in degrees
-- Position the blade in an arc above the head
local offsetX = radius * math.cos(angle) -- Left to right (X-axis)
local offsetY = radius * math.sin(angle) -- Curve above the head (Y-axis)
local offsetZ = 0 -- No forward/backward (Z-axis) movement
print(string.format("Blade %d position offsets: X=%.2f, Y=%.2f, Z=%.2f", i, offsetX, offsetY, offsetZ))
-- Combine the offsets to get the final position relative to the head's orientation
local bladePosition = Head.Position + Head.CFrame:vectorToWorldSpace(Vector3.new(offsetX, offsetY, offsetZ))
print(string.format("Blade %d world position: X=%.2f, Y=%.2f, Z=%.2f", i, bladePosition.X, bladePosition.Y, bladePosition.Z))
-- Calculate the direction tangent to the arc
local tangentAngle = angle + math.pi / 2 -- Perpendicular to the curve
local tangentX = math.cos(tangentAngle)
local tangentY = math.sin(tangentAngle)
print(string.format("Blade %d tangent direction: X=%.2f, Y=%.2f", i, tangentX, tangentY))
bladeClone.CFrame = CFrame.new(bladePosition, bladePosition + Head.CFrame:vectorToWorldSpace(Vector3.new(tangentX, tangentY, 0)))
print("Blade " .. i .. " CFrame set")
-- Weld the blade to the head to keep it in position
local weld = Instance.new("Weld")
weld.Part0 = Head
weld.Part1 = bladeClone
weld.C0 = Head.CFrame:Inverse() * bladeClone.CFrame -- Maintain the relative position
weld.Parent = bladeClone
print("Blade " .. i .. " welded to head")
end
print("All blades spawned successfully!")
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.