Melee blocking system

Hey guys!

For my group I need sabers. I’ve been working on the damage and swinging system but now I need to make blocking. How it works is the player holds right click and any time if he gets hit by another sword then it won’t do damage. But the problem is I’m having a hard time coming up with ways to make this. Any ideas or ways I can make this is loved. Thank you!

https://gyazo.com/f2cc2025197b4af04def9b6b2511ee0f

5 Likes

Perhaps you can set up some value for when a player is blocking, and the opposer’s sword will check for that value and determine whether to do damage. Obviously you’ll need to tinker with this to make it so it isn’t overpowered but it’s a start.

EDIT: I don’t work with tools often, so if this is a faulty system, feel free to correct me. :slight_smile:

This presentation shows you how to do this along with other mechanics and tips for sword fighting games.

8 Likes

Thank you I’ll be sure to check to out

1 Like

How can I find this value? I fire a event from client when the player swings. And on the server what happens is it detects the players humanoid and deals damage. You think this would work if I put this value in humanoid and when the tool hits the player it checks if it is = to true

2 Likes

Create a boolean inside of a character called Blocking and have a sword check who ever they hit if their blocking value is not nil and is false. If it is false the sword can do damage, if it is true then it can’t do damage.

3 Likes

That’s what I was thinking to do. Maybe put it in the humanoid to so its easy to locate? Where do you think I should put the boolean value?

script.Parent.Events.D.OnServerEvent:Connect(function(player)
	wait(0.3)
	Enabled = true
	script.Parent.Blade.Touched:Connect(function(Part)
		 if Enabled == true then
			Enabled = false
			if Part.Parent:FindFirstChild("Humanoid") or Part.Parent.Parent:FindFirstChild("Humanoid") then
				Enabled = false
				local Hum = Part.Parent:FindFirstChild("Humanoid") or Part.Parent.Parent:FindFirstChild("Humanoid")
				Hum:TakeDamage(math.random(30,35))
				script.Parent.Sounds.Flesh:Play()
			end	
		end
	end)
end)
3 Likes

You could just put it inside the Character or the Humanoid, it would make it simple.