Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago
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

Log in to vote
0
Answered by 10 years ago
-- 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!

0
Is it possible to write out the this without variables namelessassasin 30 — 10y
0
It is but it will take you time to do so. Variables are commonly used to make the script shorter. soldierman11 15 — 10y
Ad

Answer this question