I've always wonder how the OnTouch Function works in Roblox Lua. Could you write out the script and explain each line of code? Thx.
function OnTouch(hit) -- The start of the function, hit or anything else within those brackets is used for -- interacting with the player that activated the function. -- Code goes in here, for example, hit.Parent.Humanoid.Health = 0 end -- Ends the function script.Parent.Touched:connect(OnTouch) -- In this example the script is inside a brick that you touch, -- 'Touched' an action that triggers the function, connect is like connecting to the "function service" -- --- (doesn't exist) and OnTouch is the function your triggering.
FYI, functions only work when they are in the same script as the trigger is in.