What is the point of StarterCharacterScripts?

before you think im stupid, hear me out

StarterCharacterScripts loads code when character spawns for the first time. This means, after death it fails to function. There is a substitute event for this called Game.Players.LocalPlayer.CharacterAdded.Connect(function...)

This not only lets you update code after player resets or dies, but means you can have more cohesive code (and not have to place scripts in many folders) and you can also disconnect it upon running, making it function Exactly like StarterCharacterScripts

what is it im missing? why does StarterCharacterScripts exist. Like is it for convenience? im asking anyone who has experience in this, since if theres no difference this will affect all my (and i can assume others) future games

anyway, thanks for reading lol. all answers are appreciated

2 Likes

First of all, StarterCharacterScripts runs code every time the character spawns. Secondly I personally prefer writing:

local Players = game:GetService("Players")

local Character = script.Parent 
local Player = Players:GetPlayerFromCharacter(Character)
--code

instead of:

local Players = game:GetService("Players")

function PlayerAdded(player)
	local function CharacterAdded(char)
		--code
	end
	pcall(function()
		CharacterAdded(player.Character or player.CharacterAdded:Wait()) 
	end)
	player.CharacterAdded:Connect(CharacterAdded)
end

for _, player in pairs(Players:GetPlayers()) do 
	PlayerAdded(player)
end
Players.PlayerAdded:Connect(PlayerAdded)

PS: Placing scripts inside multiple folders makes a game more organized and ensures there’re less chances of a single script breaking the game.

6 Likes

It feels more organized, and it’s helpful for things such as LocalScripts you want to only run while that specific character is alive.

It’s also helpful to override certain scripts like the Animate and Sound scripts by adding a script to StarterCharacterScripts and renaming it to that.

4 Likes