So im trying to check if a part is on the player but im not sure how to, how would i check if a part is not and is there?
local shield = game.ServerStorage.shield:Clone()
local character = player.Character or player.CharacterAdded:Wait()
shield.Parent = character
while shield do
character.Humanoid.Health = 100
end
You can use some functioning to keep health on player, it’d be better if you’d disable causing damage on the tool or sword that is being hit against the player, but in your case here:
Make a function that keeps health 100
local HealFunc
local function Heal(Humanoid)
Humanoid.Health = 100
HealFunc = Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
Humanoid.Health = 100
end)
end
local function UnHeal()
HealFunc:Disconnect()
end)
Now you got these done, use an efficient way to check for shield if it’s on the character, and such would be by using:
Instance.ChildAddedRun an if check to see if the part added to the character is the shield and use heal() if so Instance.ChildRemovedRun an if check to see if the part removed from the character is the shield and use unheal() if so
This is more optimized way of handling your code instead of using while loop where it’s completely unnecessary
I think you’re referring to something else and you’re probably talking about a forcefield. To enable some kind of “god-mode”, use Humanoid.HealthChanged event to check if the humanoid’s health changes. If it does, reset Humanoid.Health to 100.