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

Where did i go wrong? Output tells me nothing..

Asked by 9 years ago
function onClick(player)
    local check = player.Parent:FindFirstChild("Humanoid")
    if check ~= nil then
        local user = game.Players:GetPlayerFromCharacter(player.Parent)
        print(player.Name.." was found!")
       end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

1 answer

Log in to vote
0
Answered by 9 years ago
function onClick(player)
    if player.Character:FindFirstChild("Humanoid") then -- we don't need to use that variable for the check.
        print(player.Name.." was found!")
       end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

When using onclicked, the part that clicked it doesn't return. what returns is the player that clicks it.

Ad

Answer this question