So I am using this code for my local punching script:

local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage")
local combat = rp:WaitForChild("Combat")
local m2 = rp:WaitForChild("m2")
local UIS = game:GetService("UserInputService")
local debounce = false
local cd = .5
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
repeat wait() until char:FindFirstChild("Humanoid")
local human = char.Humanoid
local curtime = 0
local prevtime = 0
local combo = 0
local m2 = 0
UIS.InputBegan:Connect(function(input,isTyping)
	if isTyping then
		return	
	elseif input.UserInputType == Enum.UserInputType.MouseButton1  then
		if
			debounce == false then
			debounce = true
			curtime = tick()
			
			local passedtime = curtime-prevtime
			print(passedtime)
			if passedtime < 1 then
				combo = combo + 1
				if combo > 4  then
					wait(1.5)
					combo = 1
				end
			else combo = 1
				
			end
			combat:FireServer(combo)
				end
			end 
end)
combat.OnClientEvent:Connect(function()
	prevtime = curtime
	wait(cd)
	debounce = false
end)

and this for my server script:

local eAnimations = script:WaitForChild("EnemyAnimations")
local limbs = {"RightHand","LeftHand","RightHand","RightFoot"}
local eanims = {eAnimations:WaitForChild("Hurt"),eAnimations:WaitForChild("Hurt 2"),eAnimations:WaitForChild("Hurt 3"),eAnimations:WaitForChild("Hurt 4")}
local m2 = rp:WaitForChild("m2")
local m2anims = {Animations:WaitForChild("Headbutt")}	
local Damage = 10	
local m2Damage= 50
local ContextActionService = game:GetService("ContextActionService")
combat.OnServerEvent:Connect(function(player,combo,stunned,enemy)
	if stunned == true then
	return
		end
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local attack = Humanoid:LoadAnimation(anims[combo])
	attack:Play()
	local folder = Instance.new("Folder",Character)
	folder.Name = player.Name.."Melee"
	local Limb = Character:WaitForChild(limbs[combo])
	local Hitbox = Instance.new("Part")
	Hitbox.Transparency = 1
	Hitbox.CanCollide = false
	Hitbox.Size = Vector3.new(3,4,3)
	Hitbox.CFrame = Character:WaitForChild(limbs[combo]).CFrame
	Hitbox.Parent = folder
	Debris:AddItem(Hitbox,.5)
	
	local weld = Instance.new("ManualWeld")
	weld.Part0 = Hitbox
	weld.Part1 = Limb
	weld.C0 = weld.Part0.CFrame: ToObjectSpace(weld.Part1.CFrame)
	weld.Parent = weld.Part0
	
	Hitbox.Touched:Connect(function(Hit)
		if Hit:IsA("BasePart")  then
			if not Hit:IsDescendantOf(Character) then
				local eHumanoid = Hit.Parent:FindFirstChild("Humanoid")
				local Hitplayer = Hit.Parent
				if eHumanoid then
					eHumanoid:TakeDamage(Damage)
					local hurt = eHumanoid:LoadAnimation(eanims[combo])
					hurt:Play()
					Hitbox:Destroy()
					if combo < 4 then
					Hitbox.Size = Vector3.new(0,0,0)
					eHumanoid.WalkSpeed = 8
					eHumanoid.JumpPower = 0
					wait(1)
					eHumanoid.WalkSpeed = 2
					eHumanoid.JumpPower = 0
					wait(1)
					eHumanoid.WalkSpeed = 16
						eHumanoid.JumpPower = 50
					else
					eHumanoid.WalkSpeed = 8
					eHumanoid.JumpPower = 0
					wait(5)
					eHumanoid.WalkSpeed = 2
					eHumanoid.JumpPower = 0
					wait(5)
					eHumanoid.WalkSpeed = 16
						eHumanoid.JumpPower = 50
					end
					
					
					
					
					
					
					end
				end
			end
		end) 
		
	
	
	
	
	combat:FireClient(player)
	
end)

What I want to do Is making a player unable to punch for the same duration that they are slowed down, how could I achieve this?

1 comment

0

i didn't have time to read the code, but maybe add an attribute/variable?