local Gui = script.Parent local Player = Gui.Parent.Parent.Parent local Char = Player.Character local Cam = game.Workspace.CurrentCamera function button() reset() end Gui.MouseButton1Click:connect(button) function reset() Char.Parent = game.Workspace local c = Char:GetChildren() Char.Humanoid.Health = 0 end
i already have the button and everything this script works but how does it work and is there a more smiple way to mka e script that kills someone
-- local variables which is used to hold a value and is easier to load than a global variable local Gui = script.Parent -- the gui points out the parent of the script local Player = Gui.Parent.Parent.Parent -- this variable points out the player itself local Char = Player.Character -- this points out the character of the player local Cam = game.Workspace.CurrentCamera function button() -- The function which is connected to the event listener. reset() -- This is the function that was written below end -- used to close the lines of the script Gui.MouseButton1Click:connect(button) -- This is the event listener. This is used to trigger the connected function function reset() Char.Parent = game.Workspace local c = Char:GetChildren() -- used to get the contents of the character of the player Char.Humanoid.Health = 0 -- the line used to kill the player by setting its health by to 0 end
The comments I wrote are written in plain English. I hope it helps!