Hi, my combat system throws an error: “attempt to call a RBXScriptConnection value” and I have no idea why.
This is the code:
local RS = game:GetService("ReplicatedStorage")
local Debounce = {}
local Combo = {}
script.Parent.Attack.OnServerEvent:Connect(function(Player)
if Player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then return end
if Debounce[Player] then return end
Debounce[Player] = true
if not Combo[Player] then Combo[Player] = 0 end
local Character = Player.Character
local Humanoid = Character.Humanoid
Combo[Player] += 1
local Hit1 = Humanoid:LoadAnimation(script.Combo.Attack1)
local Hit2 = Humanoid:LoadAnimation(script.Combo.Attack2)
local Hit3 = Humanoid:LoadAnimation(script.Combo.Attack3)
local Hit4 = Humanoid:LoadAnimation(script.Combo.Attack4)
local v1 = {}
local GeneralWaitTIme = .6
local OverallWait = 2.1
local notoca = script.Parent.Parent.Sounds.noToca
local alreadyHitObjects = {}
local tocado
tocado = script.Parent.Parent.DragonSlayer.Touched:Connect(function (hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Character.Name then
local pegado1 = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Pegado.Pegado2)
local pegado2 = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Pegado.Pegado3)
local function Speed()
hit.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
hit.Parent:FindFirstChild("Humanoid").JumpPower = 0
end
if hit.Parent.IsBlocking.Value == 0 then
if Combo[Player] == 4 then
local BV = Instance.new("BodyVelocity",hit.Parent:FindFirstChild("HumanoidRootPart"))
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 40
script.Parent.Parent.Sounds.Toca:Play()
hit.Parent.CanDamage.Value = false
hit.Parent.Humanoid:TakeDamage(5)
game.Debris:AddItem(BV,.5)
local blood = game.ReplicatedStorage.Habilities.Kogarasu.Particles.BloodPart:Clone()
blood.Parent = hit.Parent
blood.Position = hit.Parent.HumanoidRootPart.Position
for _, alreadyHit in pairs(alreadyHitObjects)do
if alreadyHit == hit.Parent.Name then
return
end
end
pegado2:Play()
task.delay(0.5, function()
pegado2:Stop()
end)
task.delay(1, function()
blood:Destroy()
end)
tocado:Disconnect()
Speed()
else
table.insert(v1, hit.Parent.Humanoid)
hit.Parent.CanDamage.Value = false
script.Parent.Parent.Sounds.Toca:Play()
v1[1]:TakeDamage(3)
local blood = game.ReplicatedStorage.Habilities.Kogarasu.Particles.BloodPart:Clone()
blood.Parent = hit.Parent
blood.Position = hit.Parent.HumanoidRootPart.Position
for _, alreadyHit in pairs(alreadyHitObjects)do
if alreadyHit == hit.Parent.Name then
return
end
end
pegado1:Play()
task.delay(0.4, function()
pegado1:Stop()
end)
task.delay(1, function()
blood:Destroy()
end)
tocado:Disconnect()
Speed()
end
end
if hit.Parent.IsBlocking.Value > 0 then
for _, alreadyHit in pairs(alreadyHitObjects)do
if alreadyHit == hit.Parent.Name then
return
end
end
script.Parent.Parent.Sounds.Blocked:Play()
hit.Parent.CanDamage.Value = false
table.insert(v1, hit.Parent.Humanoid)
hit.Parent.IsBlocking.Value = hit.Parent.IsBlocking.Value - 1
hit.Parent.Shield.Transparency = hit.Parent.Shield.Transparency + 0.4
local chispas = game.ReplicatedStorage.Habilities.Kogarasu.Particles.Chispas:Clone()
chispas.Parent = hit.Parent.HumanoidRootPart
local luz = game.ReplicatedStorage.Habilities.Kogarasu.Particles.BlockLight:Clone()
luz.Parent = hit.Parent.HumanoidRootPart
task.delay(0.5, function()
luz.Range = 5
wait(0.1)
luz.Range = 4
wait(0.1)
luz.Range = 3
wait(0.1)
luz.Range = 2
wait(0.1)
luz.Range = 1
wait(0.1)
chispas:Destroy()
luz:Destroy()
end)
tocado:Disconnect()
end
end
end)
if Combo[Player] == 1 then
Hit1:Play()
wait(GeneralWaitTIme)
tocado:Disconnect()
end
if Combo[Player] == 2 then
Hit2:Play()
wait(GeneralWaitTIme)
tocado:Disconnect()
end
if Combo[Player] == 3 then
Hit3:Play()
wait(GeneralWaitTIme)
tocado:Disconnect()
end
if Combo[Player] == 4 then
Hit4:Play()
wait(OverallWait)
tocado:Disconnect()
Combo[Player] = 0
end
delay(.4,script.Parent.Parent.DragonSlayer.Touched:Connect(function(hit)
if hit.Parent.Name ~= Character.Name then
if hit.Parent:FindFirstChild("Humanoid") and v1[1] == nil then
hit.Parent:FindFirstChild("Humanoid").WalkSpeed = 16
hit.Parent:FindFirstChild("Humanoid").JumpPower = 50
end
else
print("Not Found")
notoca:Play()
tocado:Disconnect()
end
end))
table.remove(v1, 1)
Debounce[Player] = nil
end)
![]()