Store values like numbers, names, objects:
local health = 100
local playerName = "Mahryx"
print(playerName .. "'s health is " .. health)
local function greet()
print("Welcome!")
end
greet()
Detect when something happens:
game.Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
end)
Detect when a tool is used:
local tool = script.Parent
tool.Activated:Connect(function()
print("Tool used!")
end)
Track stats like coins, kills, etc.:
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 100
coins.Parent = stats
end)