Block not working

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)

A couple of things before making a post:

  1. What is the issue? Describe it in detail because we don’t know how your system is supposed to function. All you said is that “it doesn’t work”?

  2. Are there any errors? If not try adding prints under every statement or printing the blocking value.

  3. Are you changing the blocked value on the client? If so the server won’t recognise this change.

  1. When another player blocks and another player tries to hit, it doesn’t block, that simple.

  2. No, if I was I would mention it.

  3. No, same with 2, I would have mentioned it if I was.

Fixed, I moved the part where the blocking value is created to a separate script

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.