Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What would onCharacterAdded(character, player) do inside this function?

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?

2 answers

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

This discussion is preserved as it was. New answers, comments, and votes are closed.