I am trying to get it so that this weapon will + 1 walkspeed when you attack an enemy, but the error 'attempt to index nil with ‘SelectedSOUL’.
Here is my code -
debounce = false
plr = nil
p = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
attackdebounce = false
script.Parent.Activated:Connect(function()
if debounce == false then
if plr == nil then
plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
end
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
debounce = true
script.Parent.Handle.glitch:Play()
script.Parent.Parent.HumanoidRootPart.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame + Vector3.new(math.random(6, 6),0,math.random(6, 6),0)
wait(1.7)
script.Parent.Handle.Slash:Play()
anim:Play()
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")
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()
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)
if p.SelectedSOUL.Value == game.Lighting.SOULs.Integrity then
script.Parent.Parent.Humanoid.Walkspeed += 1
hum:TakeDamage(damage+damageboost)
wait(0.5)
attackdebounce = false
end
end end
end
end
end)