Parry system help

I’m working on a small project where there are guns that use raycasting, I wanted to make a system that allows you to block shots, how can I do it?

you could do something like this

local script:

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(inp)
	if inp.KeyCode == Enum.KeyCode.E then
		game.ReplicatedStorage.Parry:FireServer()
	end
end)

server script:

local dbs = {}
local dbtime = 10
local parrytime = 2

game.ReplicatedStorage.Parry.OnServerEvent:Connect(function(plr)
	if not dbs[plr.Name] then
		dbs[plr.Name] = true
		task.delay(dbtime, function()
			dbs[plr.Name] = nil
		end)
		
		plr.Character:SetAttribute("Parry", true)
		task.wait(parrytime)
		plr.Character:SetAttribute("Parry", false)	
	end
end)

local function raycastHitPlayer(plr)
	if plr.Character:GetAttribute("Parry") then
		-- player parried
	else
		-- register the hit
	end
end

you might need to adapt the local script depending on how you want them to parry, and move the code inside the raycastHitPlayer to where you are handling the shot raycasts

1 Like

ooooh i see, tysm helped me a lot

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