✓ Accepted answer
###This is because you're attempting to access a Character inside a table. You'll have to loop though the players to get their character and destroy the head.
###Also, you should use GetPlayers over GetChildren as GetChildren is prone to script error, should an object that isn't a Player reside in the Players service.
###Instance:remove() is deprecated, switch to Instance:Destroy(). RBXScriptSignal:connect() is also deprecated, use RBXScriptSignal:Connect() instead.
###The GuiButton.MouseButton1Down event runs code whilst the mouse is held down, so the code will keep running until the mouse is no longer held down. You'll want to use MouseButton1Click, unless that's the behaviour you want.
local victims = game.Players:GetPlayers()
script.Parent.MouseButton1Click:Connect(function()
for i, v in pairs(victims) do
v.Character.Head:Destroy()
print("You killed everyone!")
end
end)
3 comments
I would accept this answer - It's really helpful :D
Thanks for your answer! What is the meaning of that 4th line? I'm really new to scripting and it would be helpful if you could explain the parameters you used and the "for something in pairs... do".
http://robloxdev.com/articles/For-Loops