Inf Health When Touching A Certain Part

oh then change the way the table is used

local part = script.Parent -- path part you want them be on, in my case its the scripts parent
local touching = {}

part.Touched:Connect(function(hit)
	
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	if touching[2] then return end
    touching = {hit.Parent.Humanoid.Health,player}
	hit.Parent.Humanoid.Health = math.huge
	
end)

part.TouchEnded:Connect(function(hit)
	
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	if not touching[2]~= player then return end
    hit.Parent.Humanoid.Health = touching[1]
	touching = {}
end)
1 Like

It’s not a shield but it’s infinite health because basically the player is invincible.
Also where would I put

if debounce == true then

end
local Circle = script.Parent
local Debounce = false


local function Touching(part)
  local parent = part.Parent
  if debounce == false then
    debounce = true
    if game.Players:GetPlayerFromCharacter(parent) then
      parent.Humanoid.MaxHealth = 200
      wait(amount)
      parent.Humanoid.MaxHealth = 100
      end
   end
 end
1 Like

add debounce = false after the wait

1 Like

Inside the parentheses or after

local Circle = script.Parent

local function TouchStarted(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
parent.Humanoid.MaxHealth = 200
end
end
local function TouchEnded(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
parent.Humanoid.MaxHealth = 100
end
end
Circle.TouchEnded:Connect(TouchEnded)
Circle.Touched:Connect(TouchStarted)

I haven’t tested this but this might work
If you want Inf helath change 200 to inf

2 Likes

Thanks for helping and happy birthday!

inf health would be math.huge btw there is no inf

But when you go to humanoid and you put the maxhealth value to like 99999999999999999999999999 it will automatically make it inf

oh yeah, setting health to inf is instant death

Ohh I didn’t know that, also you’re script works thanks a lot

Thanks to all of you that took the time out of your day to help me… I’m sorry to waste your time but I know very little about scripting and this is a big help. I really appreciate it. Again, thanks.

I’ll try to learn everything I can from this.

2 Likes