I have a Part with a Click Detector and a script that will kill the player once it is clicked and the script can find the character. It could be clicked at INF distance so Local Player wont work.
function Clicked(Player) Humanoid = Player.Character:FindFirstChild("Humanoid") if ( Humanoid ~= nil) then Humanoid.Health = 0 end end script.Parent.ClickDetector.MouseClick:Connect(Clicked)
The proper event is MouseClick not Clicked and it returns the Player not the Character.
This should work
function Clicked(plr) --Plr = Character hum = plr.Parent:FindFirstChild("Humanoid") if (hum ~= nil) then hum.Health = 0 end end script.Parent.ClickDetector.Clicked:Connect(Clicked)
I did look at it on the wiki, this is how it should be
function Clicked(plr) --Plr = Character hum = plr.Parent:FindFirstChild("Humanoid") if (hum ~= nil) then hum.Health = 0 else print("No human") end end script.Parent.MouseClick:connect(Clicked)
Problem is it cant find a humanoid. How do I figure that out?