Keep getting an error for this script:
I marked the error area. The error is: Attempt to index nil with “wait for child”
whats wrong?
local Character
local Player
local Tool = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Stabbed
local Animation = script.Parent.Stab
local StabTrack
local Cooldown = false
local CoolDownTime = 1
Tool.Equipped:Connect(function()
Character = Tool.Parent
Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
StabTrack = Humanoid:LoadAnimation(Animation)
end
end)
local attacking = false
Tool.Activated:Connect(function()
if Cooldown == false then
Cooldown = true
StabTrack:Play()
attacking = true
wait(CoolDownTime)
Cooldown = false
attacking = false
end
end)
Tool.EnhancedCone.Touched:Connect(function(Hit)
if attacking then
if Hit.Parent then
if Hit.Parent:FindFirstChild("Humanoid") then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
local plr = game:GetService("Players") :GetPlayerFromCharacter(Hit.Parent)
local vampire = plr:WaitForChild("Classes"):WaitForChild("Vampire") -- RIGHT HERE <---------
if vampire.Value == true then
Humanoid.Health -= 100
else
Humanoid.Health -= 1
end
end
end
end
end)