Kill Part script not working!

Hey, I am currently creating an obby game and am making my first obstacle which has killparts, the script I have tried is below, but it is not working.

A remote event is in the kill part.
In the output it says this:
“Players.YTFUZE123:WaitForChild(“Humanoid”)” as an error. (YTFUZE123 is my username)

Thank you.

1 Like

You don’t need a RemoteEvent and you should make sure that what touched the part has a humanoid.

1 Like

Where exactly do you see a RemoteEvent though? :thinking:

Reference the Player’s Character as @D0RYU mentioned, the Player object itself does not have the Humanoid

Alright, I will try this, thank you.

you get the humanoid from the character not the player lmao

Ok that is 100% wrong do this:

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        humanoid:TakeDamage(50) -- change 50 to anything
    end
end)
2 Likes
script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
    if hit and humanoid then
        humanoid:TakeDamage(50) -- change 50 to anything
    end
end)

:FFCWIA() is much better then :FFC()

1 Like

The humanoid object exists in the player’s character, not the player instance itself.

script.Parent.Touched:Connect(function(hit)
   local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
   if not Player then return end
   local Character = Player.Character
   if not Character then return end
   local Humanoid = Character:FindFirstChild('Humanoid')
   if not Humanoid then return end
   Humanoid.Health = 0 -- However, Character:BreakJoints() is more effective.
end)

Or :FFCOF is also good :slight_smile:

if a non humanoid class was named humanoid then that is the problem

do you mean :FFCOC()?
I don’t think that last F would stand for anything

Oop I added an F at the end sorry