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

God script problem?

Asked by 9 years ago

this script is suppose to god the health of players on touched and dis-appear when not touched

but i think there are some errors

-noviced scripter

script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") == nil then return end         
script.Parent.Character.Humanoid.MaxHealth = math.huge
script.Parent.Character.Humanoid.Health = math.huge
            end) 

2 answers

Log in to vote
1
Answered by
SirNoobly 165
9 years ago

The problem is

script.Parent.Character.Humanoid.MaxHealth = math.huge
script.Parent.Character.Humanoid.Health = math.huge

You are saying that the scripts Parent is the Player that touched it. What you want is to get the Humanoid from the hit (which you did).

script.Parent.Touched:connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then -- if humanoid doesn't == false or nil then
        humanoid.MaxHealth = math.huge
        humanoid.Health = math.huge
    end
end)
0
Yeah but 1 problem how to turn it back to normal if u aint touching it Revenant101 25 — 9y
0
Oh for that you would use TouchEnded. Also I suggest adding a debounce so it isn't constantly changing the humanoids health. SirNoobly 165 — 9y
0
tried putting debounced still the same Revenant101 25 — 9y
Ad
Log in to vote
-3
Answered by 9 years ago

Unless you have the player grouped into a model with a part, I think you'll want to change lines 3 and 4 to

hit.Parent.Humanoid.MaxHealth = math.huge
hit.Parent.Humanoid.Health = math.huge

Answer this question