Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can I can get some help with FindFirstChild("humanoid")?

So here's the deal. I've been following this tutorial: https://www.youtube.com/watch?v=u9-U2aX3osQ&t=45s and as part of it I created a script that is supposed to register register a player as a winner when they touch a brick (named "End"). However, when my player touches the brick, nothing happens. The touch is registered (I get the "I've been touched" print) but as far as I can tell it doesn't work once I hit the "if" statement. "we have a winner" never prints. Minigame.End.Touched:connect(function (hit) is where the problem appears to begin:

Minigame = script.Parent
Functions = require(script.Functions) 

Minigame.End.Touched:connect(function (hit)
	print("I've been touched") 
	local hum = hit.Parent:FindFirstChild("humanoid")
	if hum then
		local player = game.Players:GetPlayerFromCharacter(hum.Parent)
		if player then
			Functions:AddWinner(player)
			print("we have a winner")
		end
	end
end)

for i = Minigame.Minigameinfo.Time.Value, 1, -1 do
	if i == 1 then
		_G.Msg("The minigame will end in "..tostring(i).." second.")
	else
		_G.Msg("The minigame will end in "..tostring(i).." seconds.")
	end
	if #Minigame.Minigameinfo.TempContestants:GetChildren() <= 0 then
		break
	end
	wait(1)
end


Minigame.Minigameinfo.Finished.Value = true

I've completed the tutorial and double-checked all scripts among other things and still can't figure out what needs to be fixed. I get no errors in the output either. How do I get this to work?

6 comments

0

It is Connect, not connect. And Humanoid, not humanoid.

0

Make sure you spell Humanoid with a uppercase H

0

Hey dude! There are people who have answered your question! You need to accept one of their answers!

0

We don't know if that fixed his problem

0

FindFirstChild() is case sensitive, meaning that one opposite case character in a given name/string makes all the difference. You'll have to capitalize 'humanoid' to make it work (assuming that the humanoid is actually named Humanoid).

0

Sorry for keeping you all in suspense, changing "humanoid" to "Humanoid" solved the problem. Thanks for pointing out my rookie mistake!

2 answers

✓ Accepted answer

Instead of FindFirstChild("humanoid") do FindFirstChild("Humanoid")

If this helped please accept this answer.

2 comments

0

Thanks for pointing out the typo! I corrected it and everything works now.

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.