–Problem–
Im trying to have the explosion create when you hit the character, but the error Attempted to Index Nil With Parent
</> Other Info </>
- Line Of Error = 30
- Location Of Script = game.Lighting.Weapons.Stick.Tool.AttackTool
- Full Error -
22:53:06.374 - Players.PixelIGPM8.Backpack.AttackTool.Script:30: attempt to index nil with 'Parent' 22:53:06.374 - Stack Begin 22:53:06.374 - Script 'Players.PixelIGPM8.Backpack.AttackTool.Script', Line 30 22:53:06.375 - Stack End
</Code/>
debounce = false
plr = nil
attackdebounce = false
script.Parent.Activated:Connect(function()
if debounce == false then
if plr == nil then
plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
end
script.Parent.Handle.Slash:Play()
wait(.65)
local anim = nil
if script.Parent.Parent:FindFirstChildOfClass("Humanoid").RigType == Enum.HumanoidRigType.R6 then
anim = script.Parent.Parent:FindFirstChildOfClass("Humanoid").Animator:LoadAnimation(script.Parent.Handle.SlashR6)
else
anim = script.Parent.Parent:FindFirstChildOfClass("Humanoid").Animator:LoadAnimation(script.Parent.Handle.SlashR15)
end
anim:Play()
debounce = true
script.Parent.Trail.Enabled = true
wait(anim.Length)
script.Parent.Trail.Enabled = false
wait(0.5)
debounce = false
end
end)
script.Parent.Handle.Touched:connect(function(h)
if h.Parent then
local hum = h.Parent:FindFirstChildOfClass("Humanoid")
local explode = Instance.new('Explosion')
explode.Parent = hum.Parent
if hum and hum.Health > 0 then
if attackdebounce == false and h.Parent:FindFirstChild("_enemytag") then
if script.Parent.Trail.Enabled then
script.Parent.Handle.Hit:Play()
local instancenew = Instance.new('Explosion')
instancenew.Parent = script.Parent.Handle
attackdebounce = true
local damage = script.Parent.Damage.Value + (script.Parent.DamageModify.Value * (plr.LOVE.Value - 1))
local damageboost = math.floor(damage*script.Parent.DamageIncrease.Value)
hum:TakeDamage(damage+damageboost)
wait(0.5)
attackdebounce = false
end
end
end
end
end)