#why this script isn't working

18 messages · Page 1 of 1 (latest)

void mist
#

Im new scripter :)) so help me :))

white solar
gloomy lotus
#

thing is

#

here

void mist
#

Uh

gloomy lotus
#

you're saying that the part has a humanoid

void mist
#

oh lol

gloomy lotus
#

part.Parent is just the workspace.

void mist
#

Solution?

gloomy lotus
#

pass the otherpart

#

make an if statement that voids the function if the humanoid is not found

#

wait a second

void mist
#

alr

#

Thanks

gloomy lotus
#
local part = script.Parent

part.Touched:Connect(function(otherPart) --< Here, otherpart is the parameter, you need to search tutorials on lua about parameters and arguments if you don't know.
    
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid") --< we get the humanoid based on the OtherPart parent (Character) 
    
    if not humanoid then return end --< if the line above doesn't find "Humanoid", that is, the other part wasn't a character instance child, exit the function 
    
    humanoid.Health = 0  --< set the health
    
    
end)

@void mist

void mist
#

Alr thanks