So I’m trying to make this attack in this fighting game that I’m working on that sends out five sharpened bone attacks each in their own directions while they spin around as they move in a straight line.
Normally this would be easy for me to program, albeit in an unoptimized manner, but I have been making an effort to try and de-bloat my scripts lately to try and prevent as much lag as possible in my games.
The issue being though, whenever I try to test the attack by clicking the ‘Run’ button, the bones just congregate into one singular head part and don’t move after that. They used to move along with the head part before I added in code to try and make them spin around as they’re connected to the head part that’s moving in a straight line.
Here is the code for the attack:
folder=script.Parent
script.Parent.Head.hi:Play()
task.wait(1)
script.Parent.delete.Disabled = false --Enables the script that causes the attack to delete itself once a certain amount of time has passed
local bones = { --The bones in the attack, supposed to be connected to their respective head parts
bone1 = 1,
bone2 = 2,
bone3 = 3,
bone4 = 4,
bone5 = 5
}
local heads = { --The head parts in the attack, the respective bones are supposed to go on them so they can go in their own separate directions
head1 = 1,
head2 = 2,
head3 = 3,
head4 = 4,
head5 = 5
}
while true do
for _, bone in ipairs(folder:GetChildren()) do
if bones[bone.Name] then
for _, head in ipairs(folder:GetChildren()) do
if heads[head.Name] then
bone.Position = head.Position --Supposed to put the bones in the place of the head parts so they can spin without flying off track of their straight path
end
end
end
end
for _, bone in ipairs(folder:GetChildren()) do
bone.CFrame *= CFrame.Angles(0,0,-0.1) --Supposed to spin the bones
end
for _, head in ipairs(folder:GetChildren()) do
if heads[head.Name] then
head.CFrame *= CFrame.new(0,0,-2) --Moves the head parts
end
end
task.wait()
end
Whenever I run the attack, an error will pop up in the console:
CFrame is not a valid member of Script "Workspace.Bones.Script"
I tried changing “bone.CFrame *= CFrame.Angles(0,0,-0.1)” in the script to “bones.CFrame *= CFrame.Angles(0,0,-0.1)” to see if that would work, but it provided this error in the console instead:
Workspace.Bones.Script:34: invalid argument #1 (CFrame expected, got nil)
If anybody has any advice for this issue then please let me know. Any and all help will be greatly apprecated, thank you ! ^ ^