I'm trying to make a block damage on R. It continually puts the health back where it was, kinda like loopheal except it doesn't heal you. I don't want it to be like ff, where the damage is completely negated, so that if someone blocking with 30 hp takes 30 damage they die even if they're blocking. This is my attempt.
uis.InputBegan:connect(function(input)--Block if input.KeyCode == Enum.KeyCode.R then script.Parent.Parent.blocking.Value = true while script.Parent.Parent.blocking.Value == true do wait() hp = c.Humanoid.Health wait(0.1) c.Humanoid.Health = hp wait() if blocking == false then return end end end end end end)
what you can do is at the beginning of the function before the while loop save a local variable which is the value of the players health like so:
uis.InputBegan:connect(function(input)--Block if input.KeyCode == Enum.KeyCode.R then local hp = c.Humanoid.Health
then do your loop. You dont want to change the value in the while loop because it will continue to change and will not be the original value you intended. Hope this helps. Have a great day scripting!