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

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

Asked by 4 years ago

-- 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)

Closed as Non-Descriptive by imKirda and BestCreativeBoy

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

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

Ad