Thank you for looking at my question, this is a very complicated problem.
The Problem...
The problem that I am encountering in my KeyDown() code is that the first press of the code works, the "Orb" works (including the damage), the chat works, and the animation plays smoothly (sort of, working on that...) and the code does what it suppose to do. After the second press however, the chat works, but the animation and the "Orb" do not show up at all. I waited to press the KeyDown()(which is z) again, but as I pressed, I got an error that read "The Parent property of Damage is locked, current parent: NULL, new parent GreekGodOfMLG ". I've never seen an error like this before in my entire coding days (which has been 3 years now) and I'm dumbfounded on the issue as well.
My Setup...
My setup of the code is the main code called "DarkOrb" is in the StarterPack, and the code is in a local script. I have a child of the code, which is called "Damage" and as the name serves, it gives the "Orb" damage.
The Pieces of Code
The first piece of code is the local script and serves as what I like to call the "Mainframe" of all the code. Here it is:
--Parent Of Script: StarterPack
--Labels
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character.Humanoid
local Character = Player.Character
local Mouse = Player:GetMouse()
local Run = game:GetService('RunService')
local DarkOrb = Instance.new('Part', workspace)
local DarkFire = Instance.new('Fire', DarkOrb)
local Force = Instance.new('BodyVelocity', DarkOrb)
local Damage = script.Damage:clone()
local Animation = Instance.new('Animation')
Animation.AnimationId = 'https://www.roblox.com/DarkOrb-Animation-item?id=464893423'
local Track = nil
local CanPlay = true
--DarkOrb Function/Details
function onKeyDown(Key)
Key = Key:lower()
if Key == 'z' then
DarkOrb.BrickColor = BrickColor.Black()
DarkOrb.Material = 'CorrodedMetal'
DarkOrb.CanCollide = true
DarkOrb.Size = Vector3.new(10, 10, 10)
DarkOrb.TopSurface = 'Smooth'
DarkOrb.BottomSurface = 'Smooth'
DarkOrb.Shape = 'Ball'
DarkOrb.Transparency = 0.7
DarkOrb.Name = Player.Name
DarkOrb.CFrame = Player.Character.Torso.CFrame * CFrame.new(0, 0 ,-10)
--Animation Details
if CanPlay then
CanPlay = false
Track = Humanoid:LoadAnimation(Animation)
Track.KeyframeReached:connect(function(keyframename)
if keyframename == 'DarkOrb Animation' then
CanPlay = true
end
end)
Track:Play()
end
game:GetService('Chat'):Chat(Player.Character.Head, 'Feel The Darkness...DARK ORB!!!')
--DarkFire Details
DarkFire.Color = Color3.new(0, 0, 0)
DarkFire.Heat = 100
DarkFire.SecondaryColor = Color3.new(85, 0, 255)
DarkFire.Size = 100
--Force Details
Force.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Force.Velocity = Player.Character.Torso.CFrame.lookVector*85
game.Debris:AddItem(DarkOrb, 3)
--Damage Details (Child Of Script)
Damage.Parent = DarkOrb
Damage.Disabled = false
end
end
--Recalling Functions
Mouse.KeyDown:connect(onKeyDown)
Here is the second code in the script (Damage) that is the child of the first code
--Labels
local DarkBlast = script.Parent
--Damage Function
function onDamage(Dark)
if Dark.Parent:FindFirstChild('Humanoid') ~= nil and Dark.Parent.Name ~= 'script.Parent.Name' then
script.Disabled = true
for i = 1,4 do
Dark.Parent.Humanoid.Health = Dark.Parent.Humanoid.Health -15
wait(0.05)
end
script.Parent:Remove()
end
wait(0.025)
end
--Recall Functions
DarkBlast.Touched:connect(onDamage)
So...
Can you guys help me? This error is very intresting to me and I would like an answer so that I can use this as a future reference in case I come across this error again. Thanks for looking at my question, have a good day.
Greek

1 comment
Did you mean to disable the "Damage" script before causing damage to the person?