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

FindFirstChild() is ignored?

Asked by
Oficcer_F 207 Moderation Voter
5 years ago

I have a tool, that removes 18 hp from the player that gets clicked on. If the thing that gets clicked on doesn't have a humanoid, it will print("No humanoid found")

But now, it prints "No humanoid found" although I click on a player.

Tool script: (Client side, local script)

tool = script.Parent
player = game.Players.LocalPlayer


tool.Equipped:Connect(function(mouse)
    mouse.Icon = "http://www.roblox.com/asset/?id=2312592107"
    mouse.Button1Down:Connect(function()
    game.Workspace.KillExplosion.KillExplosionCreate:FireServer(mouse.Target, tool.Handle)


    end)
end)


Server script: (Server side, normal script)

debounce = false

    script.KillExplosionCreate.OnServerEvent:Connect(function(player, target, tool) 
        if debounce == false and target.Parent:FindFirstChild("Humanoid") == true then
            print("found humanoid")
            debounce = true
            wait(1)
            debounce = false
        else
            print("no humanoid found")

    end
end) 

Thank you for help!

1 answer

Log in to vote
1
Answered by
aazkao 787 Moderation Voter
5 years ago
Edited 5 years ago

remove the == true at findfirstchild, a humanoid isnt a true or a false value

debounce = false

    script.KillExplosionCreate.OnServerEvent:Connect(function(player, target, tool) 
        if debounce == false and target.Parent:FindFirstChild("Humanoid")  then
            print("found humanoid")
            debounce = true
            wait(1)
            debounce = false
        else
            print("no humanoid found")

    end
end) 

0
I still get the same error. Oficcer_F 207 — 5y
1
you sure? i tested it in studio myself aazkao 787 — 5y
1
Make sure the model you are clicking on has a humanoid in it as the descendant of target.Parent aazkao 787 — 5y
0
Let me check again. Oficcer_F 207 — 5y
View all comments (10 more)
1
and also, make sure it is named exactly Humanoid, the model i used to test this one was the drooling zombie,its a free model you can take aazkao 787 — 5y
0
Actually, when I test on a server, I did not print ANYTHING. Oficcer_F 207 — 5y
0
Ok I will test. Oficcer_F 207 — 5y
0
I will come back to you tomorrow ok? Oficcer_F 207 — 5y
1
all the printed outputs are on the server, not the individual players screens as you put the print in a server side script aazkao 787 — 5y
0
Oh! True, I will check. Oficcer_F 207 — 5y
0
You are a fu**ing genius. Oficcer_F 207 — 5y
0
Thanks man! It worked. Oficcer_F 207 — 5y
0
Now I will upvote all comments, give you some points ;) Oficcer_F 207 — 5y
0
no prob bro, thanks aazkao 787 — 5y
Ad

Answer this question