Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I dont know how to add a script that reduce damage when blocking from a combat?

-- oh and im kinda new to this site

--ServerScriptServer BlockingSystem

local rp = game:GetService("ReplicatedStorage") local Block = rp:WaitForChild("Block")

local Animations = script:WaitForChild("Animations") local Meshes = script:WaitForChild("Meshes")

Block.OnServerEvent:Connect(function(player,isActive) local Character = player.Character local Humanoid = Character:WaitForChild("Humanoid")

if isActive == true then
	--/If you are Blocking...
	local anim = Humanoid:LoadAnimation(Animations:WaitForChild("Block"))
	anim:Play()
	
	local blockAction = Instance.new("BoolValue",Humanoid)
	blockAction.Name = "blockAction"
	
elseif isActive ==false then
	--/If you Stopped Blocking...
	for i, anims in pairs(Humanoid:GetPlayingAnimationTracks()) do
		if anims.Name == "Block" then
			anims:Stop()
		end
	end
	
	local blockAction = Humanoid:FindFirstChild("blockAction")
	if blockAction then
		blockAction:Destroy()
	end
	
end

Block:FireClient(player)

end)

-- StarterPack Blocking

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

local rp = game:GetService("ReplicatedStorage") local Block = rp:WaitForChild("Block")

local UIS = game:GetService("UserInputService")

local isBroken = script.Parent:WaitForChild("isBroken")

local debounce = false local isActive = false local cd = 3

--/Press button UIS.InputBegan:Connect(function(input,isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.G then if debounce == false and isBroken.Value == false then if isActive == false then isActive = true

			Block:FireServer(isActive)
		end
	end
end	

end)

--/Button let go UIS.InputEnded:Connect(function(input,isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.G then if debounce == false and isBroken.Value == false then if isActive == true then isActive = false debounce = true

			Block:FireServer(isActive)
		end
	end
end	

end)

Block.OnClientEvent:Connect(function() wait(cd) debounce = false isActive = false end)

1 answer

You could increase the humanoid's health when you block though?

This discussion is preserved as it was. New answers, comments, and votes are closed.