✓ Accepted answer
First, you're not calling the function. You made the function but you haven't called it yet. If you would place the script inside of the button, this would be the function
function leftClick()
for i, player inpairs(game.Players:GetPlayers()) do
if player.Character then
local hum = player.Character:FindFirstChild('Humanoid')
if hum then
hum.Health = 0
end
end
end
end
We would call the function like this:
script.Parent.MouseButton1Click:Connect(leftClick)
Full Script:
function leftClick()
for i, player in pairs(game.Players:GetPlayers()) do
if player.Character then
local hum = player.Character:FindFirstChild('Humanoid')
if hum then
hum.Health = 0
end
end
end
end
script.Parent.MouseButton1Click:Connect(leftClick)
8 comments
Well said.
this did not work with no error
OK it weird now.
Wait, do you put ClickDetector to the part.
Where is the script located? Is it in the button, or where?
Try it now. I forgot to add an end. Also, I tested it in studio with the script inside of the button and it worked.
If it still doesn't work, make sure the script is inside of the button that you're clicking.
in the button