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

How would I make a script that makes a Health Damage Cooldown?

Asked by 7 years ago

How would I make it where when a player takes damage, they wouldn't be able to be hurt again until a few seconds. During this period it would make the player flash from invisible then visible again until they are able to be hurt again. Just like mario, when you get hurt, mario flashes and cant get hurt until he stops flashing. How would I do that?

0
One way you could do that is by going and having a boolValue in the player that says if they can take damage or not, and then have a script that constantly sets the players health to the max health if that value is true for damaged. That's how I would do it anyways. There are probably better ways. MrLonely1221 701 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Just insert a value into the player through a script.

ServerScriptService

game.Players.PlayerAdded:connect(function(player)
    local state = Instance.new("StringValue",player)
    state.Name,state.Value = "State","Normal"
end)

From there just have everything check if the player's state is set to normal.

local player = game.Players.LocalPlayer
repeat print("Loading") wait() until player.Character ~= nil
local character = player.Character
local delay = 3 
local states = {"Normal","Hurt"}

player.State.Changed:connect(function()
    if player.State.Value == states[2] then
        wait(delay)
        player.State.Value = states[1]
    end
end)

Pretty sure this should work.

0
where would I put the second script? Script service again? flufffybuns 89 — 7y
0
In the player scripts or player gui. Has to be a local script though. Meltdown81 309 — 7y
Ad

Answer this question