my friend told me that hit is not a valid argument of MouseButton1Click. That means hit is nil because the event MouseButton1Click does not return any arguments.
but he didnt tell me how to fix it, please help.
script.Parent.MouseButton1Click:Connect(function(hit)
local h = hit.Parent.Parent.Parent.Workspace:FindFirstChild("Humanoid")
if h then
print("Congrats!")
end
Error: https://gyazo.com/df380ba3e678d975f5430ae804ce65a8
hierarchy: https://gyazo.com/a89005bd2f1457874f86a130fcb5b4e1

6 comments
Im not quite sure what your trying to achieve on line 2.
Im trying to detect if there is a humanoid in workspace
(on click)
I posted the answer back on your other post.
Make it a LocalScript, if you're doing anything GUI wise, make it Local. Then write, script.Parent.MouseButton1Click:Connect(function() if game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") then print("Congrats") end end)
@Player1_Joined is correct with his answer.