Inf Health When Touching A Certain Part

it is not right because it is not uppercase at the begining

1 Like

you shouldn’t have it repeat wait until debounce is == true, if you touch it 5 times you will have a 5 time shield after each debounce. Just return it.

1 Like

sorry, it got myself in a loop hole. sorry again

2 Likes

So I replaced repeat with return, there’s an error

return wait() until debounce == true

try putting your code in a

if debounce == true then

end
1 Like
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[player.Name] then return end
    touching[player.Name] = hit.Parent.Humanoid.Health
	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[player.Name] then return end
    hit.Parent.Humanoid.Health = touching[player.Name]
	touching[player.Name] = nil
	
end)

I dont know if this would work but it might
it was edited from a slightly broken tool script. it worked fine except i messed up tool cloning

1 Like

you should do if touching[plr.Name] and touching[plr.Name] == nil or touching[plr.Name] then return end

1 Like

I don’t want it to be a player of my choosing. It’s like whoever created the part is the only person who gets to use it

you can just do if the player activated the move you get a shield.

1 Like

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