I am making a combat system but for some reason beyond my knowledge it isn’t working, this is only part of the script so if you need more information then I’d be happy to share, anyways here (also when I put the blocking value in a dummy as true, it still blocks):
activatedevent.OnServerEvent:Connect(function(plr, toolname, hitboxsize, hitboxoffset, weapontype, damage)
if blockingv.Value == false then
local tool = plr.Character:FindFirstChild(toolname)
local hum = plr.Character.HumanoidRootPart
if workspace:FindFirstChild(plr.Name.."Hitbox") then
workspace:FindFirstChild(plr.Name.."Hitbox"):Destroy()
end
hitbox = Instance.new("Part", workspace)
hitbox.Name = (plr.Name.."Hitbox")
hitbox.Size = hitboxsize
hitbox.Massless = true
hitbox.Color = Color3.fromRGB(255,0,0)
hitbox.Material = Enum.Material.ForceField
hitbox.Position = hum.Position + (hum.CFrame.LookVector)*hitboxoffset
hitbox.Orientation = plr.Character.HumanoidRootPart.Orientation
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= plr.Name then
if hit.Parent.Blocking.Value == false then
hit.Parent.Humanoid:TakeDamage(damage)
else
spawn(function()
local blocksound = sfx.Block:Clone()
blocksound.Parent = tool
blocksound:Play()
wait(2)
blocksound:Destroy()
end)
end
hitbox:Destroy()
end
end
end)
wait(0.2)
if hitbox then
hitbox:Destroy()
end
end
end)