So I want to create a brick that finds a player, then when it's clicked it kills that player. But the thing is I want multiple of those kill bricks that altogether will kill every player, but so that the player clicking the blocks doesnt just randomly kill people, how would I also change the name of the brick?
SUMMARY: I want to make a brick, that kills a certain player in the server, but also renames itself to the name of the player it will kill.
For example : function onClicked(playerWhoTouched) workspace.[insert name here].Humanoid.Health = 0 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
But how would I find the name in the first place?
A ClickDetector's MouseClick
event passes the Player instance of the player who clicked as first parameter to a connect
ed callback function.
local button = script.Parent button.ClickDetector.MouseClick:connect(function(player) button.Name = "Kill " .. player.Name local character = player.Character if character then local humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.Health = 0 end end end)
If you want to rename the button prior to killing the player, then you will have to get the player's Player instance differently.
Sorry, if you read the rules this is to help people with scripts and not make requests.
script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
playerWhoClicked.Humanoid.Health = 0
script.Parent.Name = playerWhoClicked.Name
end)
A simple script to find and kill on click. You can beef it up yourself.