What format is best to use when scripting? There are many ways and formats you can use to script but I’m not sure how to and which one to use. Any information you have on this topic, please inform me! I’m new to scripting and hope to become a good programmer.
You should first script variables you need for the script. Then functions and then events (such as game.Players.PlayerAdded)
Tip: If you get a reply and you think its a solution, then mark it as a solution. (Im telling you this because i saw you make multiple topics which don’t have a solution)
If your making a script such as a kill brick then you would script in this format:
local KillBrick = game.Workspace:WaitForChild("KillBrick") -- We use waitforchild because the Killbrick could've not been loaded by the time this script runs.
KillBrick.Touched:Connect(function(Touch)
if Touch.Parent:FindFirstChild("Humanoid") then
Touch.Parent.Humanoid.Health = 0
end
end)
No, it’s styling, a constant means its value cannot ever change.
// JS Example
const something = 123
-- Luau example, notice how it's a variable that just uses UPPER_SNAKE_CASE
local MY_CONSTANT_VAR = 123
MY_CONSTANT_VAR = 144
-- I can change the var, but by styling it as a constant, I tell other developers that you should not do this