Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

can someone explain this button script to me like in plain english?

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

1 answer

-- 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!

2 comments

0

Is it possible to write out the this without variables

0

It is but it will take you time to do so. Variables are commonly used to make the script shorter.

This discussion is preserved as it was. New answers, comments, and votes are closed.