I am trying to create a hitbox using a function that gets passed on 4 parameters but it is telling me that I attempt to call a table value.
This is the function call:
hitBox(hitBox, rootPart, humanoid, combo)
This is the function:
function hitbox(hitBox ,rootPart, humanoid, combo)
hitBox.Touched:Connect(function(hit, hum)
if hum == humanoid then return end
if hum.Parent:Getattribute("Radgolled") or hum.Health <= 0 then return end
local humRp = hum.HumanoidRootPart
local center = (humRp.Position - humRp.Position).Unit
local strength = 10
if combo == MaxCombo then
ragdoll = true
strength = 35
end
local knockback = center * strength
if downslam then
knockback = Vector3.new(0, -30, 0)
hum:TakeDamage(5)
return
end
hum:TakeDamage(math.random(2, 3.5))
if combo == 2 then
local animator2 = hum.Animator
local animation2 = Instance.new("Animation")
animation2.AnimationId = Animations.toRight
local track = animator2:LoadAnimation(animation2)
track:Play()
track:AdjustSpeed(.7)
task.wait(.75)
track:Stop()
else
local animator2 = hum.Animator
local animation2 = Instance.new("Animation")
animation2.AnimationId = Animations.toLeft
local track = animator2:LoadAnimation(animation2)
track:Play()
track:AdjustSpeed(.85)
task.wait(.75)
track:Stop()
wait(.25)
hum.WalkSpeed = 16
end
coroutine.resume(coroutine.create(function()
local effect = ReplicatedStorage["Impact punchs effects particles"]:Clone()
effect.Position = hit.Position
effect.Parent = workspace
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=8595975878"
sound.PlaybackSpeed = 1.2
sound.Volume = .75
sound.Parent = hit
sound:Play()
hum.WalkSpeed = 7.5
wait(.25)
effect:Destroy()
end))
end)
end