So I'm following a roblox tutorial on the dev wiki and they do
local function onCharacterAdded(character, player) end player.CharacterAdded:Connect(function(character) onCharacterAdded(character, player) end)
The part I don't understand is what is the purpose of onCharacterAdded(character, player) when its already in the first function?
This script will run when the player joins the game, hence the name onCharacterAdded
.
what the script does is, whenever it detects a CHARACTER added into workspace, it runs the character added function. the CHARACTER parameter is the character of the player.
if u remove the last 3 lines nothing will even run because onCharacterAdded() is a function, and functions need to be called to be able to run. so by saying player.CharacterAdded:Connect(function()) end
CALLS the onCharacterAdded() function
EDIT: j