A lot of the time, when I test out my code an error pops up, saying "attempt to index nil with '(certain property)'. If you know how to fix this, please respond.
Code:
game.ReplicatedStorage.SkillEvents["Holy Judgement Skill Events"]["Sun Pillar"].OnServerEvent:Connect(function(player, mousePos) local HolyJudge = game.ReplicatedStorage["Holy Judgement Magic Skills"]["Sun Pillar Skill"] local SunPillar = HolyJudge["Sun Pillar"]:Clone() local SunPillarExplode = HolyJudge["Sun Pillar Explosion"]:Clone() local character = player.Character local localplayer = script.Parent local HolyJudgeCircle = game.ReplicatedStorage["Holy Judgement Magic Skills"].HolyJudgeMagicCircle2:Clone() local HolyJudgeAura = game.ReplicatedStorage["Holy Judgement Magic Skills"].HolyJudgeAura:Clone()
--local mouse = game.Players.LocalPlayer:GetMouse()
--// \\--
--|Sun Pillar|--
--\\ //--
wait(1)
HolyJudgeCircle.Position = character.LeftFoot.Position
HolyJudgeAura.Position = character.HumanoidRootPart.Position
SunPillar.Position = character.HumanoidRootPart.Position
HolyJudgeCircle.Parent = workspace
HolyJudgeAura.Parent = workspace
SunPillar.Parent = workspace
print("Checkpoint1") local velocity = Instance.new("BodyVelocity", SunPillar) velocity.Velocity = CFrame.new(SunPillar.Position, mousePos).lookVector * 1
print("Checkpoint2")
--// \\--
--|Sun Pillar Explosion|--
--\\ //--
SunPillar.Touched:Connect(function(hit)
if hit:IsDescendantOf(character) or hit:FindFirstChild("ParticleEmitter") then return end
SunPillarExplode.Position = SunPillar.Position
wait(1)
HolyJudgeCircle:Destroy()
HolyJudgeAura:Destroy()
SunPillar:Destroy()
SunPillarExplode.Parent = workspace
print("Checkpoint3")
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
wait(0.5)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
wait(0.5)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
wait(0.5)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
wait(0.5)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
--else
--hit.Parent:FindFirstChild("Humanoid"):TakeDamage(-100)
end
print("Checkpoint4")
wait(3)
SunPillarExplode:Destroy()
print("Checkpoint5")
end)
end)

1 comment
The error message attempt to index nil means that your attempting to change something in the workspace that doesnt exist try using waitforchild for an object in the workspace except humanoids.