function onPlayerEntered(newPlayer)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local c = Instance.new("IntValue")
	c.Name = "Cash"
	c.Value = 20

	c.Parent = stats

	stats.Parent = newPlayer 

	newPlayer.Changed:connect(function (property)
		if (property == "Character") then
			onPlayerRespawned(newPlayer)
		end
	end)
end

game.Players.ChildAdded:connect(onPlayerEntered)

2 comments

0

Where is the function onPlayerRespawned defined????

0

in addition to what zamd said :connect() is deprecated, use :Connect(). onPlayerRespawned is what I'm assuming happens to a player when they respawn, so you'd need to define that. If you you don't want that, remove the player.Changed event call.