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

Any ideas on how to make a effective combat blocking script?

I currently have a block script that does work in some cases but I feel as if it could be much more efficient. The script spawns a invisible brick in front of the player that serves as the means of blocking the way the player is facing. It works fine with my hand to hand combat script but when using a tool that has more reach than a fist, the attack just seems to phase right through the block as if it never touched it and damages the player. Should I be trying a different method of making of a block script or...?

2 comments

0

Maybe post the scripts

0

You could probably just make the Player's Humanoid who is using the block invincible

2 answers

My suggestion would be to make the humanoid invincible like DAsanicmaster said by using the HealthChanged event

local humanoid = character.Humanoid -- humanoid variable
humanoid.HealthChanged:Connect(function()
	humanoid.Health = humanoid.MaxHealth
end)

You could do..

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()

local blocking = false

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.R and not blocking then --Also, could be written as [[inputObject.KeyCode == "R"]]
        blocking = true
        local nodamage = Instance.new("ForceField", Character.Torso)
        nodamage.Visible = false
       wait(5)
       nodamage:Destroy()
       blocking = false
    end 
end)

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