Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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...?

0
Maybe post the scripts User#19524 175 — 6y
0
You could probably just make the Player's Humanoid who is using the block invincible DAsanicmaster 52 — 6y

2 answers

Log in to vote
2
Answered by 6 years ago

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)
Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question