I was watching a tutorial on a combat system and I am having a problem with a script that is the exact same to the script on the tutorial but gives me an error. This is the script.
local MuchachoHitbox = require(game.ServerStorage.modules["MuchachoHitboxV1.1"])
local HitService = require(game.ServerStorage.modules.HitService)
local CombatTable = require(game.ServerStorage.modules.CombatTable)
--print(CombatTable)
--[[game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:SetAttribute("Combo", 1)
end)
end)--]]
local remote = game.ReplicatedStorage:WaitForChild("CombatEvent")
local lastremote = game.ReplicatedStorage:WaitForChild("LastHit")
local MaxCombo = 5
local function SetCombo(CV)
local combo = CV.Combo
if combo < MaxCombo then
CV.Combo += 1
else
CV.Combo = 1
end
end
local function ComboReset(CV, oldcombo)
task.delay(1, function()
local currentcombo = CV.Combo
if oldcombo == 5 then return end
if currentcombo-1 == oldcombo and not CV.Attacking then
CV.Combo = 1
end
end)
end
remote.OnServerEvent:Connect(function(player)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local rootpart = humanoid.RootPart
local animator = humanoid.Animator
local Attributes = CombatTable[character]
local combo = Attributes.Combo
local attacking = Attributes.Attacking
local stunned = Attributes.Stunned
local blocking = Attributes.Blocking
if attacking or stunned or blocking then return end
Attributes.Attacking = true
local animations = game.ReplicatedStorage["punch anims"]:GetChildren()
local animation = animator:LoadAnimation(animations[combo])
local hitbox = MuchachoHitbox.CreateHitbox()
hitbox.Size = Vector3.new(6,6,6)
hitbox.Offset = CFrame.new(0,0,-2.5)
hitbox.CFrame = rootpart
--hitbox.Visualizer = false
task.delay(.25, function()
ComboReset(Attributes, combo)
hitbox:Stop()
if combo == 5 then
humanoid.WalkSpeed = 5
task.wait(1)
end
humanoid.WalkSpeed = 16
Attributes.Attacking = nil
end)
hitbox.Touched:Connect(function(hit, hum)
if hum == humanoid then return end
local function fx()
local effectsFolder = game.ReplicatedStorage.fxfolder
local attachment = Instance.new("Attachment")
attachment.Parent = hum.RootPart
local particle = effectsFolder.hitfx:Clone()
particle.Parent = attachment
particle:Emit(5)
local sound = effectsFolder.hitsfx:Clone()
sound.Parent = attachment
sound:Play()
local hitanims = game.ReplicatedStorage["hit anims"]:GetChildren()
local hitanim
if combo == 1 or combo == 3 then
hitanim = hum:LoadAnimation(hitanims[1])
elseif combo == 2 or combo == 4 then
hitanim = hum:LoadAnimation(hitanims[2])
elseif combo == MaxCombo then
hitanim = hum:LoadAnimation(hitanims[3])
end
hitanim:Play()
game.Debris:AddItem(attachment, .1)
game.Debris:AddItem(sound, .3)
end
if combo < MaxCombo then
HitService.Hit(hum, 5, .1, rootpart.CFrame.LookVector*10, false, fx)
else
HitService.Hit(hum, 10, .3, rootpart.CFrame.LookVector*100, true, fx)
end
end)
humanoid.WalkSpeed = 7
animation:Play()
task.wait(.16)
hitbox:Start()
SetCombo(Attributes)
end)
The error is :